You problem, as stated, actually has no inteest in joining these tables. What you appear to be trying to do can be accomplished through:
---u.user_id = 1---AND
------exists ( select 1 from table2 r where r.user_id = u.user_id) OR
------exists ( select 1 from table3 s where s.user_id = u.user_id) OR
------exists ( select 1 from table4 t where t.user_id = u.user_id) OR
------exists ( select 1 from table5 g where g.user_id = u.user_id)
03-30-2001, 03:55 AM
What Gary asked for is if the user exists in *any* of the tables. From looking at Chris' solution, what this will do is report the username if it appears in table 1 *and* one of the others.
I think that a union will satisfy the basic requirement:
from table1 u
from table2 r
from table5 g
03-30-2001, 10:14 AM
True, but I made some assumptions to reach that conclusion. He 'said' he wanted the result if it existed in *any* table, yet the way he wrote the statement, it looked as if he assumed that it existed first in table1. If my assumption was incorrect, then Dave_A has the correct solution.
03-30-2001, 10:44 AM
chrislong was right. I was looking for a value that existed in ANY of the tables. The EXIST operator worked like a charm!