UNION Simple Mistake

When you create a query, a common error is to include an ORDER BY clause in your UNION (or UNION ALL) in the first part of the query.  This will cause a syntax error since an ORDER BY clause can’t be included in just one part of a UNION. The ORDER BY is performed on the entire query, so it must come at the very end of the overall query statement.





Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.