我有两个桌子。
TableA(% is a wild card character)
---------------
str |
---------------
abc% |
xyz% |
pop% |
---------------
TableB
--------------------
id | name | domain |
--------------------
1 | Paul | zzz.ko |
2 | John | abc.lo |
3 | Kal | pop.cm |
--------------------
我想从TableB中提取所有记录,其中domain
与TableA str
字段不匹配(通配符匹配)。
粗查询看起来像这样:
select * from TableB b
where not exists (select 1 from TableA a where b.domain like a.str)
此外,您可能要避免使用“ str”作为列名。