Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8281091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:54:47+00:00 2026-06-08T09:54:47+00:00

This came up at work and this really just seems like a puzzle… Query

  • 0

This came up at work and this really just seems like a puzzle…

Query 1:

SELECT * FROM
SYSIBM.SYSTABLES A LEFT JOIN
SYSIBM.SYSTABLESPACE B
ON A.DBNAME = B.DBNAME
AND A.TSNAME = B.NAME
AND A.TSNAME LIKE 'HIB%'
;

This query does NOT filter on the HIB% criteria, contrary to what it LOOKS like the query should be doing. I would THINK that putting that criteria in the JOIN should deliver identical results.

Query 2 works as expected:

SELECT * FROM
(SELECT * FROM SYSIBM.SYSTABLES
WHERE TSNAME LIKE 'HIB%') A
LEFT JOIN
SYSIBM.SYSTABLESPACE B
ON A.DBNAME = B.DBNAME
AND A.TSNAME = B.NAME
;

What is wrong with the first query?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:54:50+00:00Added an answer on June 8, 2026 at 9:54 am

    TRY

    SELECT * FROM SYSIBM.SYSTABLES A 
    LEFT JOIN SYSIBM.SYSTABLESPACE B 
      ON A.DBNAME = B.DBNAME AND A.TSNAME = B.NAME 
    WHERE A.TSNAME LIKE 'HIB%' ; 
    

    When you put the condition in the left join that is used to filter the records for the join, but since is a left join it is returning all the records from table A becasue you put no conditions on that.

    Now it would have been different if the condition was on table B. The it belongs in the left join (unless it is something like B.id is null) or you will turn the query back into an inner join.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just came up with this, it seems to work in all modern browsers,
I just started with cocos2D and came across something that looks like this ..
Problem This question actually came up at work today. We are planning an experiment
This question came up from what I see on a clients side: Intermittent Connection
I just don't know what to think anymore. It seems like the people who
Hello my fellow Stackoverflownians :), I just came across this thing called Zend. And
This is a really stupid question, but I'm just drawing a blank here... What
This came up recently in a class for which I am a teaching assistant.
This question came to my mind when I learned C++ with a background of
This question came today in the manipulatr mailing list. http://groups.google.com/group/manipulatr/browse_thread/thread/fbab76945f7cba3f I am rephrasing. Given

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.