MySQL Forums
Forum List  »  General

Is it possible to get MORE results by adding an AND clause to a SQL query?
Posted by: kris helenek
Date: November 05, 2010 10:00AM

For some reason I get more results after I add a superfluous AND clause to the end of a query, which I only tried out of desperation. The more I thought of this, that should never be possible, right? (Unless the and is part of an OR, but that's extending an existing clause, not adding a new one.)

Here's my query:
select l.address_id, d.location_address_id, a.id
from distance d, address a, location l
where member_latitude = 42.4039 and member_longitude = -71.1203 and distance < 25
and location_latitude = a.latitude and location_longitude = a.longitude
and l.address_id = d.location_address_id
#and a.id = l.address_id

If I run that I get 13 results. If I uncomment the last line I get 88. The results either way show that all three values involved are the same! It should be a redundant check right?

Is my database completely corrupt? Or having I been staring at it too long and missed something obvious.

Any help is appreciated, my site is in serious trouble until I fix this.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.