Slim
Slim

Reputation: 1744

Can't get the order by working

I have this query:

     EDITED

The problem is that after executing the query I'm getting this error:

Incorrect syntax near the keyword 'union'.

I am missing somthing?

Upvotes: 0

Views: 56

Answers (1)

Luca Davanzo
Luca Davanzo

Reputation: 21520

If you take a look at the documentation at:

C. Using UNION of two SELECT statements with ORDER BY

you'll see that you can't use ORDER BY in the first query.

Remember that:

  • number and the order of the columns must be the same in all queries.
  • data types must be compatible.

Upvotes: 2

Related Questions