Re: [GENERAL] problem with subselect: NOT IN

2001-04-02 Thread Tom Lane
Kevin L <[EMAIL PROTECTED]> writes: > However, getting employees who have NOT sold something always > returns zero rows: > SELECT emp_id FROM employee WHERE emp_id NOT IN (SELECT emp_id > FROM workorder); Probably you have some NULL values in workorder. See past discussions about why NOT IN and

Re: [GENERAL] problem with subselect: NOT IN

2001-04-02 Thread Peter Eisentraut
Kevin L writes: > However, getting employees who have NOT sold something always > returns zero rows: > > SELECT emp_id FROM employee WHERE emp_id NOT IN (SELECT emp_id > >FROM workorder); Are there any NULL values in workorder.emp_id? If so, you need to exclude them (... FROM workorder WHERE em

Re: [GENERAL] problem with subselect: NOT IN

2001-04-02 Thread Patrik Kudo
Hi To start with, I think your queries will be faster if you don't use IN, but instead used regular joins or EXISTS whenever possible On Mon, 2 Apr 2001, Kevin L wrote: > The following works fine: (get all employees who have sold > something) > > SELECT emp_id FROM employee WHERE emp_id IN (SEL

[GENERAL] problem with subselect: NOT IN

2001-04-02 Thread Kevin L
Hi. here's my scenario: table employee has emp_id and employee details. table salesorder has emp_id and sales details. The following works fine: (get all employees who have sold something) SELECT emp_id FROM employee WHERE emp_id IN (SELECT emp_id FROM salesorder); However, getting employees w