Answer the question
In order to leave comments, you need to log in
Query on two PostgreSQL tables?
Hello, help me to correctly form the request, something is confused.
There is a Field - an identifier in one table, there is another table in which the same identifiers (Users) may be present.
A query is needed that will display the user if he is in the first table, or in the second table + another condition for the second table, for example is_active.
The second table may contain several entries for this user.
Answer the question
In order to leave comments, you need to log in
SELECT `id` FROM `t1` UNION SELECT `id` FROM `t2` WHERE `is_active` = 1
SELECT id FROM (
SELECT id FROM tbl1
UNION
SELECT id FROM tbl2 WHERE is_active = 1
) WHERE id = SOME_ID
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question