The following bug has been logged online:
Bug reference: 5122
Logged by: Muris Pucic
Email address: trax@multicom.ba
PostgreSQL version: 8.2
Operating system: Vista
Description: Subqueries - inner select statement bug
Details:
Hi,
If we have two simple tables:
TABLE1
------
id
first_name
TABLE2
------
id
last_name
##############
EXAMPLE QUERY:
##############
-- The query below works, even though there is no column "first_name" in
TABLE2. This should return an error but it does not, it returns all rows
from TABLE1. This query should not evaluate correctly even when aliases are
not used because it can be misleading.
SELECT * FROM TABLE1 WHERE first_name IN (SELECT first_name FROM TABLE2)
-- The query below works as expected
SELECT * FROM TABLE1 WHERE first_name IN (SELECT last_name FROM TABLE2)
Regards,
Muris
www.elektronika.ba