Results 1 to 8 of 8
  1. #1
    Amedeo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    4

    Access Query to show non dups 2 fields. 1 table

    I'm not an SQL expert so I was looking for some help that would allow me to get the following results using 1 table:

    Field1 ID is an auto record ID, field2 ID is actually field1 ID assigned that record, in other words record 1 has a roommate (record 5) assigned to it, record 2 has a roommate (record 4) assigned to it

    Table A

    Field1 ID Field2 ID
    1 5
    2 4
    3 6


    4 2
    5 1
    6 8
    Results records I'm looking to display for would be:
    1 5
    2 4
    3 6
    6 8

    I only want to display all fields for records, but I don't want to show their matching record, so I want to display record1, but not record 5 because record 1 has record 5 as a roommate, want to display record 2 but not record 4, hope this makes sense.

    Thanks,
    Amedeo

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    What is in Field2 when there is NO roommate?

  3. #3
    Amedeo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    4
    Quote Originally Posted by RuralGuy View Post
    What is in Field2 when there is NO roommate?
    It's just blank, i had a query to just select non blanks in field 2 to eliminate people with no roommates.

    Thanks

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So if the table were sorted by Field1 number and the number in Field2 is < the number in Field1 then it would have already been included in the Recordset, right?

  5. #5
    Amedeo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    4
    Yes, field 1 is just the record auto ID which all records will have, when a roommate is assigned to a record basically we are adding the same record ID into that records RoommateID field on the same table.

    I've attached a sample database, so based on the sample data,

    If the query works it should show only the following 4 records:
    record 4 but not 5
    record 6 but not 7
    record 8 but not 12
    record 9 but not 11

    I have a pre-query in the database to eliminate all records that do not have a roommate.

    Thanks,
    Amedeo
    Attached Files Attached Files

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try the query now.
    Attached Files Attached Files

  7. #7
    Amedeo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    4
    Awesome, looks like it works!!

    Just so you know the reason behind this, this list is supplied to the hotels, so the hotels only want to see the name of the person once, if we were to pull all the records with roommates without this query you would see:

    john smith rooming with jane smith and
    jane smith rooming with john smith

    Thanks for you help, really appreciate it.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You're welcome. All I did was implement the suggestion I had in Post #4.

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

Similar Threads

  1. Replies: 3
    Last Post: 08-21-2012, 05:56 AM
  2. Replies: 2
    Last Post: 08-07-2012, 03:58 PM
  3. Fields show differently in table versus form.
    By zero3ree in forum Access
    Replies: 1
    Last Post: 08-01-2012, 03:58 PM
  4. Replies: 2
    Last Post: 01-24-2012, 02:16 PM
  5. Show data not in table A using multiple fields
    By mikesmith01 in forum Access
    Replies: 3
    Last Post: 02-25-2011, 08:38 AM

Tags for this Thread

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