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

  • Home
  • SEARCH
  • 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 6909287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:40:13+00:00 2026-05-27T08:40:13+00:00

The 2 following queries are giving me different results: SELECT A.source_code, B.quantity FROM Table_A

  • 0

The 2 following queries are giving me different results:

SELECT A.source_code, B.quantity
FROM Table_A AS A
LEFT JOIN Table_B AS B ON B.merchant_id = A.merchant_id
   AND B.agent_id = A.agent_id
   AND B.default IS NULL
WHERE A.month='2011-10-01'
   AND B.type='600'

And

SELECT A.source_code, B.quantity
FROM Table_A AS A
LEFT JOIN Table_B AS B ON B.merchant_id = A.merchant_id
   AND B.agent_id = A.agent_id
WHERE A.month='2011-10-01'
   AND B.type='600'
   AND B.default IS NULL

I had assumed that the condition does the same operation on both queries, only at different times. Am I missing something?

  • 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-27T08:40:13+00:00Added an answer on May 27, 2026 at 8:40 am

    They are and should be different.

    Consider the case where you have an a with a b that matches on merchant and agend id’s, and b.default is not null.

    In the first case, you will find the a, and then find no b’s that meet the criteria, because there is no b that matches on the id’s AND has default is null. But because it’s a left join, you still get a record with the “a” data in the output.

    In the second case, you will find the a and find a matching b. But because b fails the WHERE clause, the record is excluded from the output.

    If you are doing a full join, putting a condition in an ON versus a WHERE will not change the output. But on a left or right join, it DOES change the output in the way I tried to describe above.

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

Sidebar

Related Questions

Why are the following queries different? I want a LEFT OUTER join, but need
I have the following queries, QryStockOnHand SELECT QrySaleTot.Item, QrySaleTot.ProductID, [QryStockLevel].[Stock]-[QrySaleTot].[Quantity] AS StockOnHand FROM QryStockLevel
The following two queries each give the same result: SELECT column FROM table GROUP
Consider the following 2 queries: select tblA.a,tblA.b,tblA.c,tblA.d from tblA where tblA.a not in (select
I have the following two queries: select count(*) from segmentation_cycle_recipients scr , segmentation_instance si
Can anyone please explain to me why the following two queries yield different results?
I have the following queries: Query 1: Select * from T10,T11,T12,T13,T14 where T10.C0 =
Consider the following queries. select * from contact where firstname like '%some%' select *
Which of the two following queries might be faster? $cposts = mysql_query(SELECT id FROM
I have the following queries - SELECT COUNT(capture_id) as count_captures FROM captures WHERE user_id

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.