Latest Post

Error: No input file specified.

While trying to run a codeigniter app the other day I came across this error just after I had finished uploading the files and making the ne...

Thursday, May 28, 2009

Incorrect usage of UNION and ORDER BY

A common problem when using the UNION command in MySQL is when you want to order the sets of data 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 individual SELECT statement in brackets as shown below:

(SELECT * FROM table1)
(SELECT * FROM table2)

No comments:

Post a Comment

Chitika Ads