Union Query Sorting

R

Robert Raley

Access 2003

I am using the following query and would like to know how I can sort the
output on the following fields.

ContId ASC, common_name ASC.

Thanks

Robert M Raley

SELECT ContId, com_name, studio FROM qry_mod_min_F4F;
UNION
SELECT ContId, com_name, studio FROM qry_mod_min_PS;
UNION
SELECT ContId, com_name, studio FROM qry_mod_min_DS;
UNION
SELECT ContId, com_name, studio FROM qry_mod_details;
UNION
SELECT ContId, name, studio FROM qry_mod_insurance;
UNION
SELECT ContId, com_name, studio FROM qry_mod_manager;
UNION SELECT ContId, com_name, studio FROM qry_mod_shift;
 
K

Ken Snell [MVP]

Assuming you mean "com_name" instead of "common_name":

SELECT ContId, com_name, studio FROM qry_mod_min_F4F;
UNION
SELECT ContId, com_name, studio FROM qry_mod_min_PS;
UNION
SELECT ContId, com_name, studio FROM qry_mod_min_DS;
UNION
SELECT ContId, com_name, studio FROM qry_mod_details;
UNION
SELECT ContId, name, studio FROM qry_mod_insurance;
UNION
SELECT ContId, com_name, studio FROM qry_mod_manager;
UNION SELECT ContId, com_name, studio FROM qry_mod_shift
ORDER BY ContId, com_name;


For a union query, the ORDER BY goes at the end of the query, and it must
use the names from the first query in the UNION query.
 
R

Robert Raley

Thanks Ken as always you are a great help. I really need a spelling teacher.
Worked like a charm.

Bob
 
K

Ken Snell [MVP]

You're welcome.

--

Ken Snell
<MS ACCESS MVP>

Robert Raley said:
Thanks Ken as always you are a great help. I really need a spelling
teacher.
Worked like a charm.

Bob
 
Top