Let's say I have two tables A and B, each of which has an integer ID column. I want to find ID values that occur in A but not B. The first query I came up with was:

SELECT ID FROM A WHERE NOT EXISTS (SELECT * FROM B WHERE B.ID = A.ID);

but I get a syntax error.  My next try,

SELECT ID FROM A WHERE ID NOT IN (SELECT ID FROM B);

works and is probably more efficient, but I'm just curious what's wrong with the first one.
--
  James W. Walker, ScriptPerfection Enterprises, Inc.
  <http://www.write-brain.com/>

Reply via email to