Tom Wildt
Tom Wildt

Reputation: 113

MYSQL Query - ORDER BY in UNION - Descending Order

Using Microsoft Access. Is it possible to sort the ORDER BY column as Descending?

SELECT * FROM 
(
  SELECT table1.* FROM table1 ORDER BY table1.field1
) DUMMY_ALIAS1

UNION ALL

SELECT * FROM
( 
  SELECT table2.* FROM table2 ORDER BY table2.field1
) DUMMY_ALIAS2

Upvotes: 1

Views: 73

Answers (1)

Mureinik
Mureinik

Reputation: 312289

Yes - just add desc after the field name:

SELECT * FROM 
(
  SELECT table1.* FROM table1 ORDER BY table1.field1 DESC
) DUMMY_ALIAS1

UNION ALL

SELECT * FROM
( 
  SELECT table2.* FROM table2 ORDER BY table2.field1 DESC
) DUMMY_ALIAS2 

Upvotes: 2

Related Questions