469,362 Members | 2,491 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

please help

if I want to find a user_id from table 1 which does not exist in the
table 2(possible multiple entries for any user_id). the user_id in
table 2 is a subset from table 1.
if I can not use subquery and minus, how can I do it?
thanks.

Jul 12 '06 #1
2 1668
jz********@gmail.com wrote:
if I want to find a user_id from table 1 which does not exist in the
table 2(possible multiple entries for any user_id). the user_id in
table 2 is a subset from table 1.
if I can not use subquery and minus, how can I do it?
Use an outer join. Where there is no match, there you have a user_id
that does not exist in table2.

SELECT t1.user_id
FROM table1 AS t1
LEFT OUTER JOIN table2 AS t2 ON t1.user_id = t2.user_id
WHERE t2.user_id IS NULL;

Regards,
Bill K.
Jul 12 '06 #2
thanks. Bill.
really helpful
Bill Karwin wrote:
jz********@gmail.com wrote:
if I want to find a user_id from table 1 which does not exist in the
table 2(possible multiple entries for any user_id). the user_id in
table 2 is a subset from table 1.
if I can not use subquery and minus, how can I do it?

Use an outer join. Where there is no match, there you have a user_id
that does not exist in table2.

SELECT t1.user_id
FROM table1 AS t1
LEFT OUTER JOIN table2 AS t2 ON t1.user_id = t2.user_id
WHERE t2.user_id IS NULL;

Regards,
Bill K.
Jul 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by tyler_durden | last post: by
23 posts views Thread by Jason | last post: by
5 posts views Thread by tabani | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.