【问题标题】:Use IN operator along with NOT LIKE considering wild card matching使用 IN 运算符和 NOT LIKE 考虑通配符匹配
【发布时间】:2019-12-26 15:53:39
【问题描述】:

我有两张桌子。

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 sap-ase


    【解决方案1】:

    粗略的查询如下所示:

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

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

    【讨论】:

      猜你喜欢
      • 2013-02-08
      • 1970-01-01
      • 2012-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-30
      相关资源
      最近更新 更多