Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Location
    California
    Posts
    502

    Unanswered: Append Query Results to another Query?

    Is it possible to run Query1, then run query2 and append the results to query1?

    Both have same fields and structures.

    What about resorting query1 after query two result is appended.

    Thanks . . . Rick

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    SELECT <fields>
    FROM yourTable
    UNION
    SELECT <fields>
    FROM yourOtherTable
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    'append' to a query ...maybe not, but how about UNION ?

    for example in a single query:
    SELECT tblA.fldG AS XX FROM tblA
    UNION ALL
    SELECT tblB.fldH As XX FROM tblB
    ORDER BY XX

    experiment with and without the ALL depending on the result you are looking for (e.g. if there are duplicate values in tblB.fldH)

    izy

    sorry Teddy - i type slowly
    currently using SS 2008R2

  4. #4
    Join Date
    Mar 2007
    Posts
    1
    if query1 and query2 are based on different tables then the union is the way to go. However, if your two queries are using the same tables it's much more efficient to just create a third query. Example, I have seen people do the following:

    q1
    Code:
    select name from tblStudents where gender = 'Male';
    q2
    Code:
    select name from tblStudents where gender = 'Female';
    q3
    Code:
    select name from q1
    union
    select name from q2;
    hth,
    Giacomo

Posting Permissions

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