Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2002
    Posts
    173

    Unanswered: combining tables

    I have three queries all with identical information that I'd like to combine into one. For example:
    query1
    name phone address

    query2
    name phone address

    query3
    name phone address

    How would I create a query to combine all 3 queries into one? I'm using access97.

    newquery
    name phone address

  2. #2
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    A union query is what you cheifly need.

    Make a query, do not chose any tables, view the SQL and type in the following.

    SELECT [Name], [Phone], [Address]
    FROM [query1]

    UNION SELECT [Name], [Phone], [Address]
    FROM [query2]

    UNION SELECT [Name], [Phone], [Address]
    FROM [query3]
    ORDER BY [Name];


    I've never done more than two, so my syntax may be off. Hope this helps you get started.
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  3. #3
    Join Date
    Jun 2002
    Posts
    173
    Tried out the code to combine all the tables. I actually combined 12 queries into one. Works great except out of 727 combined records it leaves out 5. They happen to be the exact same in each query. ie. query 5 and query 6 each have identical records so it omits one of them. Is there a way of avoiding this?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    to avoid duplicate records from being eliminated automatically, use UNION ALL instead of UNION



    rudy
    http://rudy.ca/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •