If you need to sort the output from two queries grouped together with a UNION operator, you need to apply the ORDER BY clause at the group level, not at the subquery level. for example: (SELECT * FROM sample WHERE tag = 'MCA' ORDER BY created) UNION (SELECT * FROM sample WHERE tag = 'BCA' ORDER BY created)
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
for example:
(SELECT * FROM sample WHERE tag = 'MCA' ORDER BY created)
UNION
(SELECT * FROM sample WHERE tag = 'BCA' ORDER BY created)