RE: Opposite selection...

2003-02-06 Thread Jennifer Goodie
A Left join using IS NULL will work. You can get the syntax and see an example in the manual http://www.mysql.com/doc/en/JOIN.html >From the maunal... If there is no matching record for the right table in the ON or USING part in a LEFT JOIN, a row with all columns set to NULL is used for the righ

Re: Opposite selection...

2003-02-06 Thread Brent Baisley
I think you are coming from the wrong angle. If you want the opposite, you should reverse your approach. Select all the names in the projects table, match them with names in the contacts, then filter it so you only have the ones without a match. SELECT p.name,p.company FROM projects p LEFT JOIN

Re: Opposite selection...

2003-02-05 Thread Benjamin Pflugmann
Hi. On Tue 2003-02-04 at 12:25:08 -0500, [EMAIL PROTECTED] wrote: > Ok I'm stumped on what I think should be a somewhat simple query. What I > have so far is a list of names that is in a list of projects AND in a the > main contact list by doing the following query: > SELECT p.name, p.company FROM

Re: Opposite selection...

2003-02-05 Thread Brian Lindner
Nicholas, Tuesday, February 4, 2003, 12:25:08 PM: > Ok I'm stumped on what I think should be a somewhat simple query. What I > have so far is a list of names that is in a list of projects AND in a the > main contact list by doing the following query: > SELECT p.name, p.company FROM contacts c, pro

Re: Opposite selection...

2003-02-05 Thread Nasser Ossareh
refer to 1.7.4.1 Subselects in the manual for the answer. here's a brief example: The queries: SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2); SELECT * FROM table1 WHERE NOT EXISTS (SELECT id FROM table2 WHERE table1.id=table2.id); Can be rewritten as: SELECT table1.* FROM tab