Page 1 of 1

Simple query help please

Posted: Fri May 09, 2008 7:39 am
by cybercog
Two tables:

t1 = a list of ID's as int (1 - 100)

t2 = a list of ID's from t1 that get used during a year (2,4,6,8,9,20)

How do I get a list of ID's from t1 that are NOT also listed in t2? (the ones unused in t1)

I can easily get it when I want the ones used, but the unused is not working right.

Thanks

Re: Simple query help please

Posted: Fri May 09, 2008 9:07 am
by Apollo
SELECT id FROM t1 WHERE NOT id IN (SELECT id FROM t2)

Just curious: if you had difficulty selecting the unused ones, but you were able to easily select the used ones, how did you do it?

Re: Simple query help please

Posted: Fri May 09, 2008 9:33 am
by cybercog
Thanks, that worked great.

I just did a simple SELECT on the two tables and compared id's

I've got to study more, that's for sure.

Thanks