Results 1 to 3 of 3
  1. #1
    mokhecen is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    1

    query show who dosent has medal3

    i want to make a query show me only who dosent has medal3
    the table has tow fields Fname and Medalname
    Fname Medalname


    rony medal1
    rony medal3
    sam medal1
    john medal3
    john medal2
    tony medal1


    the answer must be only "sam and tony"

  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,641
    Presuming you have a table of the people, I see a two step solution. Create a query that returns all the people who do have medal3, then use the unmatched query wizard to compare that query to the table of people, which will give you everybody who does not have medal3.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jameslarsen is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Location
    Los Angeles, CA
    Posts
    20
    Try using the NOT IN operator:

    SELECT Fname
    FROM MyTable
    WHERE Fname NOT IN
    (
    SELECT Fname
    FROM MyTable
    WHERE Medalname="medal3"
    )

    If the NOT IN query is too slow (uses more resources to calculate), you can also use a LEFT JOIN query:

    SELECT T1.Fname
    FROM MyTable AS T1 LEFT JOIN
    (
    SELECT Fname
    FROM MyTable
    WHERE Medalname = "medal3"
    ) AS T2 ON T1.Fname = T2.Fname
    WHERE T2.Fname Is Null

    James A. Larsen
    Database Architect, Data Analyst, and Business Intelligence Specialist
    james.larsen42@gmail.com

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

Similar Threads

  1. Show only last record in query
    By robsworld78 in forum Queries
    Replies: 18
    Last Post: 09-02-2011, 08:36 PM
  2. Check dosent update current date
    By bsunuwar in forum Access
    Replies: 10
    Last Post: 03-23-2011, 09:46 PM
  3. Query to show only last entry
    By kroenc17 in forum Queries
    Replies: 20
    Last Post: 10-18-2010, 01:53 PM
  4. Show last residence using a query
    By jeffyyy in forum Queries
    Replies: 3
    Last Post: 10-18-2010, 08:42 AM
  5. Query, show top 10
    By lostinspace in forum Queries
    Replies: 4
    Last Post: 05-10-2010, 12:18 PM

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