Have table where are two columns – client_id, content
every client have +- 50 content rows.
In WHERE i have this clause – where content NOT IN ('2','3','4')
In result shows same clients but without rows where are ‘2’,’3′,’4′. I need if found one client with content ‘2’,’3′,’4′ dont show this client completely
Advertisement
Answer
NOT IN
only removes the rows with ‘2’,’3′ or ‘4’ in the content column.
Use NOT EXISTS
:, the following query will return all client_id without ‘2’ ‘3’ or ‘4’ in the content column
SELECT DISTINCT client_id FROM [your table] AS t WHERE NOT EXISTS (SELECT 1 FROM [your table] WHERE content in('2','3','4') and [your table].client_id = t.client_id)