In some queries, for example UNION, ORDER BY clause doesn't seem to work so what to do in that situation? Is there any similar clause to ORDER BY?
Like there is a similar clause to "LIMIT x" is "SELECT TOP x" where x is the numeric number.
In some queries, for example UNION, ORDER BY clause doesn't seem to work so what to do in that situation? Is there any similar clause to ORDER BY?
Like there is a similar clause to "LIMIT x" is "SELECT TOP x" where x is the numeric number.
If you want to order the individual selects in an union, you need parentheses and a LIMIT:
(SELECT a FROM b ORDER BY c LIMIT 10)
UNION
(SELECT d FROM e ORDER BY f LIMIT 10)
If you want to sort the union, again, use parentheses:
(SELECT a FROM b)
UNION
(SELECT d FROM e)
ORDER BY x
You can also read this in the manual.
This post answers your question. You don't need a different clause to ORDER BY, just a different structure to your query.