How to use SELECT UNION with different ORDER BY statements?
I have the following query:
(SELECT
Url, Ref, Text, DateTime, 'C1' AS Source
FROM Table
WHERE Category = 'C1')
UNION
(SELECT
Url, Ref, Text, DateTime, 'C2' AS Source
FROM Table
WHERE Category = 'C2')
UNION
(SELECT
Url, Ref, Text, DateTime, 'C3' AS Source
FROM Table
WHERE Category = 'C3')
ORDER BY DateTime DESC
Now I need to merge another query, that has a different "ORDER BY":
UNION
(SELECT
Url, Ref, Text, Expiration, 'C4' AS Source
FROM Table
WHERE Category = 'C4' AND Expiration >= CURDATE()
ORDER BY Expiration ASC)
I've tried to add it as above, but it doesn't work.
What's wrong?
Thanks in advance.