Jump to content

Subtracting Tables - Solved With Our Thanks In The Final Post


niche

Recommended Posts

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

SELECT DISTINCT cliorder FROM stk WHERE NOT EXISTS (SELECT * FROM trkg WHERE stk.cliorder = trkg.cliorder)

Link to comment
Share on other sites

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...