--- Original Message -
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 v
> 5,8,x,y,z,u,v,w,t
>
> This Works ok, HOWEVER, if Table2 Has no Data, the query returns NO results.
> What I want it to return is:-
> 1,8,x,y,z,u,v,w,t
> 2,8,x,y,z,u,v,w,t
> 3,8,x,y,z,u,v,w,t
> 4,8,x,y,z,u,v,w,t
> 5,8,x,y,z,u,v,w,t
>
> any Takers?
>
> Regards
>
uot; <[EMAIL PROTECTED]>
To: "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
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" <[
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 p
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
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
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: