使用IN运算符以及不喜欢使用通配符匹配的方式

问题描述 投票:0回答:1

我有两个桌子。

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字段不匹配(通配符匹配)。

database sybase sybase-ase
1个回答
0
投票

粗查询看起来像这样:

select * from TableB b
where not exists (select 1 from TableA a where b.domain like a.str)

此外,您可能要避免使用“ str”作为列名。

© www.soinside.com 2019 - 2024. All rights reserved.