因此,我试图从我“联合所有”的这2个表中过滤出ID。基本上,如果ID包含某个名称,我想将其从查询中过滤掉。这是一个例子
ID,Name
1,Mark
1,John
2,Peter
2,Matt
3,Henry
3,Matt
4,John
4,Olaf
因此,我不想包含包含“ Matt”的ID,这意味着我想完全过滤掉ID 2和3。
使用类似的东西:
select *
from name.table
where name not like 'Matt'
似乎只能过滤掉该行。
您可能想做这样的事情:
select * from table where id not in(
select Id from table where name like '%Matt%'
)
这不包括名称包含Matt的行
排除等于Matt的行
select * from table where id not in(
select Id from table where name ='Matt'
)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句