Bug or expected behaviour

From: Ravinder Bhalla <Ravinder(dot)Bhalla(at)ipix(dot)com>
To: sfpug(at)postgresql(dot)org
Subject: Bug or expected behaviour
Date: 2003-12-12 19:24:56
Message-ID: 7BF4AEDBD413334CB37BD66D4DBB9636821BC0@sr-strongbad
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: sfpug

Could someone pls explain me the following,

I have two table tables emp and dept

emp
----------
empid
empname
dept_no
age

dept
----------
deptid
deptname

billdb=# select * from dept\g
deptid | deptname
--------+----------
100 | Oracle
200 | PHP

(2 rows)


billdb=# select * from emp;
empid | empname | dept_no | age
-------+---------+---------+-----
1 | Abhay | 100 | 24
2 | AB | 200 | 26
(2 rows)



billdb=# select * from emp where empid in ( select empid from dept);
empid | empname | dept_no | age
-------+---------+---------+-----
1 | Abhay | 100 | 24
2 | AB | 200 | 26
(2 rows)


Why the query is returning rows when empid column doesn't exists in dept
table. Should throw an error.

Thanks
Ravinder

Responses

Browse sfpug by date

  From Date Subject
Next Message Patrick Hatcher 2003-12-15 20:47:06 Re: Bug or expected behaviour
Previous Message Stephan Szabo 2003-12-02 20:03:59 Re: Meeting? November/December