Answer the question
In order to leave comments, you need to log in
How to correctly compose a query using the UNION operator?
There are two tables:
1) comment
id | task_id | date
1 | 1 | 1
2 | 1 | 2
3 | 2 | 2
id | task_id | date
11 | 1 | 3
21 | 1 | 2
(SELECT C.id, date FROM comment AS C WHERE C.task_id = 1)
UNION
(SELECT D.id, date FROM deal AS D WHERE D.task_id = 1)
ORDER BY date
id | date
1 | 1
22 | 1
2 | 2
11 | 3
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question