Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,982
    Thanks
    120
    Thanked 76 Times in 76 Posts

    normalized table query

    Code:
    name  surname  car
    
    bill      gates     bmw
    bill      gates     renault
    john   doe        renault 
    ...
    how to find who does not have bmw ?
    Last edited by BubikolRamios; 03-15-2013 at 03:48 AM.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,603
    Thanks
    80
    Thanked 4,500 Times in 4,464 Posts
    ??? What does this have to do with Normalization???

    There is not such thing as a one-table database that is normalized.

    However...
    Code:
    SELECT DISTINCT t1.name, t1.surname, t2.surname AS usedAsFlag
    FROM table AS t1
    LEFT JOIN ( SELECT name, surname FROM table
                WHERE car = 'bmw' ) AS t2
    ON t1.name = t2.name
    AND t1.surname = t2.surname
    HAVING usedAsFlag IS NULL
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    BubikolRamios (03-18-2013)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •