View Single Post
  #6 (permalink)  
Old November 1st, 2005, 02:24 PM
Jeff Mason Jeff Mason is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:
...without using sub selects...
Not sure what you mean by that comment...

A UNION query is made up of two or more SELECT statements combined with the UNION operator, as:
Code:
    SELECT col1, col2, col3, ...
    FROM <sometable>
    WHERE ...
UNION
    SELECT colA, colB, colC, ...
    FROM <someothertable>
    WHERE ...
ORDER BY col1, ...
The ORDER BY clause applies to the results of the UNION as a whole. The resultset of a UNION has the column names (and datatypes) of the first SELECT statement, so the ORDER BY clause refers to columns in that first query.


Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
Reply With Quote