Reputation: 485
So I have this table (table1):
I need to know all the 'num' who dont know HTML
I tried - SELECT num FROM table1 WHERE package <> HTML
The problem is, for example, that NUM 2 knows Excel aswell, so he still shows up in the result...
Any ideas?
Upvotes: 1
Views: 51
Reputation: 44874
Here is another way of doing it using not exists
select
distinct num from table_name t1
where not exists
(
select 1 from table_name t2
where t2.package = 'HTML'
and t1.num = t2.num
)
Upvotes: 3
Reputation: 33391
Try this:
SELECT DISTINCT num
FROM table1
WHERE num NOT IN (SELECT num FROM table1 WHERE package = 'HTML')
Upvotes: 3
Reputation: 12904
SELECT DISTINCT num FROM table1
WHERE
(num NOT IN (SELECT num FROM table1 WHERE package = 'HTML'))
I don't have access to a MySQL box at this moment, but that should work.
Upvotes: 3