Results 1 to 7 of 7
  1. #1
    kbp is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    11

    Query to find matching records in 2 tables

    Hi there i'm not sure that the title to this question is correct, but basically i've got 2 tables, that have very similar data in.



    an [enrolment] table which holds information about clients and where they enrolled. A client could have enrolled on a course from 1 of 7 different sites.

    and an [outcomes] table which holds information about the clients after the course.

    i have created a query to filter out records from the [enrolment] table so i only see the records from a specific site.

    i have created another query to display records from the [outcomes] to only view certain records.

    now i want to cross-refference the 2 queries to only display records that occur in both queries, and a seperate query that displays records that dont occur in both queries.

    anyone know how to do this??

    cheers
    Andy

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    you can use the IN subquery. for instance, syntax:
    Code:
    select whatever from table where field (NOT) IN (SELECT whatever from othertable)
    if your records have unique identifiers to them, it's even better because the subquery only has to take one field in it as an arg.

  3. #3
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    records that occur in both queries:
    select * from query1 inner join query2 on query1.id=query2.id

    records that occur in query1 not occur in query2:
    select * from query1 left join query2 on query1.id=query2.id where query2.id is null

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    you can still inner join datasets if they are not related?

  5. #5
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    they are related by clients

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,737
    How about showing us the Table structures?
    And what specifically you want the query/queries to do/show?

  7. #7
    kbp is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    11
    hiya guys thanks for the tips, been out of the office most of the day and haven't had a chance to try your ideas... They all look good though and i can see where your going with them!! I'll give them a go when i get a chance and let you know.

    cheers

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

Similar Threads

  1. Concatenating fields from matching records
    By MWMike in forum Queries
    Replies: 1
    Last Post: 10-28-2010, 10:49 PM
  2. Replies: 2
    Last Post: 09-01-2010, 09:51 PM
  3. Replies: 9
    Last Post: 06-23-2010, 02:06 PM
  4. Matching between 2 tables
    By slevin in forum Access
    Replies: 1
    Last Post: 06-16-2010, 07:28 AM
  5. Find Records Query
    By sullyman in forum Programming
    Replies: 1
    Last Post: 10-28-2009, 08:49 AM

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