tags:

views:

22

answers:

1

I have a table with uuid and system column. I need a query to return only uuid's having system=1 but not the uuids with system= 1 and 2

+1  A: 
SELECT  *
FROM    mytable m
WHERE   system = 1
        AND NOT EXISTS
        (
        SELECT  NULL
        FROM    mytable mi
        WHERE   mi.uuid = m.uuid
                AND mi.system = 2
        )
Quassnoi
+1: This more clean to my thorough approach
OMG Ponies
The case is just an example. I will have more system types not just 1 and 2. Also I need a way to find uuid with say 1,2,3 and 3,4,5, 3 being the common value