RE: Select from one table where ID not in another table

2003-09-02 Thread Dathan Vance Pattishall
Use LEFT JOIN SELECT t1.*, t2.id FROM table1 as t1 LEFT JOIN table2 as t2 ON t1.id=t2.id WHERE t2 IS NULL; -- something like that -- ---Original Message- --From: Martin Moss [mailto:[EMAIL PROTECTED] --Sent: Tuesday, September 02, 2003 1:50 PM --To: [EMAIL PROTECTED] --Subject: Select

Re: Select from one table where ID not in another table

2003-09-02 Thread Martin Moss
Sorry I missed out the difficult bit, query sould read:- SELECT table1.*,table2.id from Table1 AS table1,Table2 AS table2 WHERE table1.otherkeyid = '7236523' AND table2.otherkeyid = '7236523' AND table1.id DOESN'T EXIST IN table2.id; If there are NO entries in table2 for otherkeyid I still want

Re: Select from one table where ID not in another table

2003-09-02 Thread Martin Moss
Sorry I missed out the difficult bit, query sould read:- SELECT table1.*,table2.id from Table1 AS table1,Table2 AS table2 WHERE table1.otherkeyid = '7236523' AND table2.otherkeyid = '7236523' AND table1.id DOESN'T EXIST IN table2.id; If there are NO entries in table2 for otherkeyid I still want

Re: Select from one table where ID not in another table

2003-09-02 Thread Kelley Lingerfelt
select t1.* from table1 t1 LEFT JOIN table2 t2 on t1.id=t2.id WHERE t2.id IS NULL you can print out table2 values if you want, but they will all be NULL.. provided that table2.id and table1.id are the matches you are trying to find. Kelley Martin Moss wrote: All, Am wondering if it's

Re: Select from one table where ID not in another table

2003-09-02 Thread Matt W
Hi Marty, Yes, a query like this: SELECT t1.* FROM table1 t1 LEFT JOIN table2 t2 ON (t2.id=t1.id) WHERE t2.id IS NULL This assumes that table2.id is defined as NOT NULL. See also: http://www.mysql.com/doc/en/JOIN.html Hope that helps. Matt - Original Message - From: Martin Moss

Re: Select from one table where ID not in another table

2003-09-02 Thread Martin Moss
[EMAIL PROTECTED] Sent: Tuesday, September 02, 2003 10:27 PM Subject: RE: Select from one table where ID not in another table Well, in order for that to work, you will need to do an explicit JOIN somewhere or else the IS NULL or NOT NULL won't work. You might try... SELECT table1.*, table2.id

Re: Select from one table where ID not in another table

2003-09-02 Thread Kelley Lingerfelt
] Sent: Tuesday, September 02, 2003 10:27 PM Subject: RE: Select from one table where ID not in another table Well, in order for that to work, you will need to do an explicit JOIN somewhere or else the IS NULL or NOT NULL won't work. You might try... SELECT table1.*, table2.id FROM table1

Re: Select from one table where ID not in another table - Solved

2003-09-02 Thread Martin Moss
- From: Martin Moss [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 02, 2003 10:47 PM Subject: Re: Select from one table where ID not in another table I'm not sure if I've described the exact results I want very well, but thanks to everyone for your help so far, hope you