Results 1 to 4 of 4
  1. #1
    path is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    2

    Query to select only records with certain values

    Sorry if this has been hashed over before, but I searched to see if I could find something similar...



    I have a large database with over 1MM records. It is a database of reservation records, with 15 separate tables. I am attempting to do two things: find records containing ONLY certain field values, and none of the other possible values, and find records that do NOT contain those values.

    Example: I need to find records that contain one of three values, and also contain one of 3 other values, but no additional values. The record needs to contain one of these 3 values - UO ADM, UO ADM FL or FLEX ADM, and it also needs to contain one of three other values - CW INCLUSION, TP TRANS or EPA. I don't want records that include any other values.

    I'm fairly new to db queries, so I'm not sure if this is something simple, or complicated.

    Any help is appreciated!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I assume those are two different fields? Try

    SELECT...
    FROM...
    WHERE Field1 IN("UO ADM", "UO ADM FL", "FLEX ADM") AND Field2 IN("CW INCLUSION", "TP TRANS", "EPA")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    path is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    2

    Thanks, but...

    Thank you for responding.

    Unfortunately, each subset of values is in the same field. This is what is making it so difficult. Because I need one from the first subset, and one or more from the second subset - and no others from that field - it makes it very difficult to get just the records I need.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I would think you could use Like with wildcards or the InStr() function, and logic like:

    (A OR B OR C) AND (D OR E OR F)

    where each of the letters was a test using Like or InStr(). If you're still stuck, a sample db a few records and the expected result would help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. How to use a subform to select and use records
    By shiphtfour in forum Forms
    Replies: 3
    Last Post: 01-02-2011, 01:04 PM
  2. select statement inside values?
    By hung_ko in forum Access
    Replies: 4
    Last Post: 01-01-2011, 10:06 PM
  3. Replies: 5
    Last Post: 11-02-2010, 10:41 AM
  4. Replies: 2
    Last Post: 03-25-2010, 12:11 PM
  5. select records in recordset
    By sksriharsha in forum Programming
    Replies: 3
    Last Post: 09-05-2009, 11:40 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