所以我有这个表(table1):
我需要知道所有不懂HTML的'num'
我试过 - SELECT num FROM table1 WHERE package <> HTML
问题是,例如,NUM 2也知道Excel,所以他仍然出现在结果中......
有什么想法吗?
答案 0 :(得分:3)
SELECT DISTINCT num FROM table1
WHERE
(num NOT IN (SELECT num FROM table1 WHERE package = 'HTML'))
此刻我无权访问MySQL框,但这应该可以。
答案 1 :(得分:3)
试试这个:
SELECT DISTINCT num
FROM table1
WHERE num NOT IN (SELECT num FROM table1 WHERE package = 'HTML')
答案 2 :(得分:3)
以下是使用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
)