Results 1 to 2 of 2
  1. #1
    JAPA1972 is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Jan 2019
    Posts
    14

    Nested union query

    I have a union query attached to a combobox with a query field called LASTNAME. Unfortunately the records are not sorted by LASTNAME as the UNION query messes up with the order. How can I have all the records in the UNION query sorted by LASTNAME? Do I have to create a nested query? If so, how? Thanks.




    SELECT FIRSTNAME, LASTNAME FROM TABLE1 ORDER BY LASTNAME UNION FIRSTNAME, LASTNAME FROM TABLE2 ORDER BY LASTNAME

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,973
    Just use order by after the final union
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 08-09-2017, 12:06 PM
  2. Convert Union Query to non-union help
    By Ekhart in forum Queries
    Replies: 2
    Last Post: 01-10-2017, 03:39 AM
  3. Replies: 4
    Last Post: 12-20-2015, 02:35 PM
  4. Nested And/Or query
    By kagoodwin13 in forum Queries
    Replies: 2
    Last Post: 05-10-2012, 12:10 PM
  5. Nested SQL Query
    By springboardjg in forum Queries
    Replies: 5
    Last Post: 05-08-2011, 05:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums