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 6059339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:41:58+00:00 2026-05-23T08:41:58+00:00

If you use a LEFT JOIN and also have a WHERE clause, are all

  • 0

If you use a LEFT JOIN and also have a WHERE clause, are all the conditions in the WHERE clause being disregarded if the table that you tried to join does not exist?

In other words, do I have to specifically compare against the id from the LEFT JOIN?

SELECT distinct(watchedItems.id) 
FROM globalItems, watchedItems 
  LEFT JOIN bidGroups ON bidGroups.bidGroupID = watchedItems.bidGroupID

WHERE    
  watchedItems.aid = globalItems.aid 
  AND watchedItems.processRunning = 0
  (watchedItems.bidGroupID IS NULL 
  OR (watchedItems.bidGroupID IS NOT NULL AND bidGroups.bidGroupQty > 0))

Could I write instead of the entire last bit just

AND bidGroups.bidGroupQty > 0

and it will not be tested because bidGroups does not exist if the LEFT JOIN fails? I know that without the LEFT JOIN it will definitely test against it all the time, which means if this test fails, the entire statement is not executed. But I want it to be executed in any case (with and without bidGroups.)

  • 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-05-23T08:41:58+00:00Added an answer on May 23, 2026 at 8:41 am

    If the table doesn’t exist your statement won’t parse and will result in a SQL exception.

    EDIT

    I’d write your query this way, for readability:

    SELECT distinct(watchedItems.id)
    FROM globalItems INNER JOIN
         watchedItems ON globalItems.aid = watchedItems.aid LEFT JOIN
         bidGroups ON bidGroups.bidGroupID = watchedItems.bidGroupID
    WHERE
        watchedItems.processRunning = 0
    AND (watchedItems.bidGroupID IS NULL
         OR (watchedItems.bidGroupID IS NOT NULL
         AND bidGroups.bidGroupQty > 0)
    );
    

    The answer to whether you need to check watchedItems.bigGroupID IS NOT NULL is no, you do not have to as the join condition already covers that.

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

Sidebar

Related Questions

How can I use MySQL to count with a LEFT JOIN? I have two
I have a Materialized view in Oracle that contains a LEFT JOIN which takes
Studying compilers course, I am left wondering why use registers at all. It is
I currently have a closure table used for hierarchical data that has 5 million
I have a query like this: SELECT TaFellesVaktjournal.*, TaBygg.ByggNavn FROM TaFellesVaktjournal LEFT JOIN TaBygg
I have a parent category that holds all Cars names, denoted by parent_name in
So I have a MySQL query that is being created dynamically based on parameters
Okay, my dilemma is this. I have an admin page that I use to
We are having a debate in our company. I use left outer joins quit
How do you use the LEFT function (or an equivalent) on a SQL Server

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.