Incorrect usage of UNION and ORDER BY
A common problem using the UNION command in MySQL is when you want to order data sets differently. If you do it incorrectly, you will see the error message: Incorrect usage of UNION and ORDER BY To solve the problem, wrap each SELECT statement in parenthesis as follows: Nice and simple; all you have to…