JosefSchmidt
MIS
Is it possible to select a row if it exists in at least one of three tables? For example, if 3 different tables all contain a field named "USERID", can I obtain a list of all the USERIDs that are in at least 1 of the 3 tables?
Currently I'm using a SQL statement similar to the following:
SELECT DISTINCT a.userid
FROM table a
WHERE a.userid IN (SELECT DISTINCT b.userid FROM tableb b)
OR IN (SELECT DISTINCT c.userid FROM tablec c)
OR IN (SELECT DISTINCT d.userid FROM tabled d)
The problem is that I have WHERE criteria in each of the subqueries which makes the query a memory hog.
Any thoughts/advice?
Currently I'm using a SQL statement similar to the following:
SELECT DISTINCT a.userid
FROM table a
WHERE a.userid IN (SELECT DISTINCT b.userid FROM tableb b)
OR IN (SELECT DISTINCT c.userid FROM tablec c)
OR IN (SELECT DISTINCT d.userid FROM tabled d)
The problem is that I have WHERE criteria in each of the subqueries which makes the query a memory hog.
Any thoughts/advice?