472,125 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,125 software developers and data experts.

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 1698
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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.