niche Posted October 1, 2011 Share Posted October 1, 2011 is there a keyword that's the opposite of UNION? i need to subtract table trkg.cliorder from table stk.cliorder. Link to comment Share on other sites More sharing options...
niche Posted October 1, 2011 Author Share Posted October 1, 2011 SELECT DISTINCT cliorder FROM stk WHERE NOT EXISTS (SELECT * FROM trkg WHERE stk.cliorder = trkg.cliorder) Link to comment Share on other sites More sharing options...
Ingolme Posted October 1, 2011 Share Posted October 1, 2011 I'm not absolutely certain, but I think NOT IN will work: SELECT field1, field2, field3 FROM table1 WHERE indexfield NOT IN (SELECT field FROM table2) Edit: Well, it seems you have a solution already. You should do the research BEFORE asking a question, not after. Link to comment Share on other sites More sharing options...
niche Posted October 2, 2011 Author Share Posted October 2, 2011 Thanks Ingolme. I value your help very much. I do research (sometimes a lot) before I start a topic and I continue to research when time allows. Please excuse me for answering my own question. I kept working on it and found the answer at: http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html (one of the few times the answer fell out of the manual for me). Posting it seemed like the right thing to do. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.