1. Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!

Access Question

Discussion in 'BBS Hangout' started by AMS, Dec 6, 2011.

  1. AMS

    AMS Member

    Joined:
    Oct 8, 2003
    Messages:
    9,646
    Likes Received:
    218
    I have to write an access query to find a user that doesnt have a particular color. So in this data set I need to find users that don't have the color Magenta.

    James - Red
    James - Blue
    James - Magenta
    Gary - Red
    Gary - Violet
    Jeffry - Red
    Jeffry - Magenta
    George - Blue
    George - Green
    April - Magenta
    April Blue

    The result needs to be just the users without Magenta
    Gary
    George
     
    #1 AMS, Dec 6, 2011
    Last edited: Dec 6, 2011
  2. AMS

    AMS Member

    Joined:
    Oct 8, 2003
    Messages:
    9,646
    Likes Received:
    218
    Any help is appreciated.

    I have tried Select Distinct
    and Group By and neither are giving the result I want.
     
  3. SwoLy-D

    SwoLy-D Member

    Joined:
    Jul 20, 2001
    Messages:
    37,618
    Likes Received:
    1,456
    This is NOT an access question, it's a QUERY question... but, anyway: let's see your SQL statements, sir? :confused:

    Maybe we can go from there to see how you're coming up with some records.
     
  4. wangzhizhi

    wangzhizhi Member

    Joined:
    Jun 28, 2006
    Messages:
    85
    Likes Received:
    1
    select *
    where color<>'magenta'
     
    1 person likes this.
  5. AMS

    AMS Member

    Joined:
    Oct 8, 2003
    Messages:
    9,646
    Likes Received:
    218
    That gives you


    James - Red
    James - Blue
    Gary - Red
    Gary - Violet
    Jeffry - Red
    George - Blue
    George - Green
    April Blue

    .....

    I need it to exclude the whole subset if it has Magenta.
     
  6. AMS

    AMS Member

    Joined:
    Oct 8, 2003
    Messages:
    9,646
    Likes Received:
    218

    SELECT Distinct Name
    FROM Table1
    WHERE (((Name) Like "Magenta"));

    This gives me all the names that HAVE Magenta:
    James
    Jeffry
    April

    And if I do

    SELECT Distinct Name
    FROM Table1
    WHERE (((Name) NOT Like "Magenta"));

    I get all the names because there are other records that don't have Magenta.

    :confused:
     
  7. bobrek

    bobrek Politics belong in the D & D

    Joined:
    Sep 16, 1999
    Messages:
    36,288
    Likes Received:
    26,645
    You have stated two different outcomes that you desire.

    1 (from original post) - you need to find a user that does not have a particular color, which is what appears that wangzhizhi provided.

    2 (from this post) - you need to exclude an entire subset if magenta is included as a color. What exactly are you looking for?
     
  8. AMS

    AMS Member

    Joined:
    Oct 8, 2003
    Messages:
    9,646
    Likes Received:
    218
    I guess I didn't explain it correctly, but I was looking for

    2.


    However, I think I got it figured out using

    Select *
    From Table1
    Where Color Not in(
    Select Distinct Name
    From Table1
    WHere Color Like "Magenta");


    It wasn't working earlier because I was using a a NOT IN Statement with a NOT Like and it was blowing up access.

    Thanks guys!
     

Share This Page

  • About ClutchFans

    Since 1996, ClutchFans has been loud and proud covering the Houston Rockets, helping set an industry standard for team fan sites. The forums have been a home for Houston sports fans as well as basketball fanatics around the globe.

  • Support ClutchFans!

    If you find that ClutchFans is a valuable resource for you, please consider becoming a Supporting Member. Supporting Members can upload photos and attachments directly to their posts, customize their user title and more. Gold Supporters see zero ads!


    Upgrade Now