【问题标题】:How to use LIKE statement in sql plus with multiple wild carded values?如何在 sql plus 中使用带有多个通配符值的 LIKE 语句?
【发布时间】:2011-01-10 03:15:27
【问题描述】:

我的问题是,目前如果我想查询多个通配符值。我需要做这样的事情。

select customername from customers where customername like '%smith' or customername like '%potter' or customer name like '%harris' or customername like '%williams';

所以我想问问专家,有没有更简单的方法来做到这一点?

问候, 桑詹

【问题讨论】:

  • 为什么你有的不容易?
  • 想想匹配 100 个名字

标签: oracle wildcard sqlplus sql-like


【解决方案1】:

创建一个包含 100 个名字的表格

select customername from customers c inner join customersames cn on(c.customernamename like '%'+cn.searchForname)

如果有帮助,可以是一个表变量。

【讨论】:

    【解决方案2】:

    你可以使用正则表达式

    编辑:您可以在网上找到大量资源。以http://66.221.222.85/reference/regexp.html 为例。

    正则表达式确实很强大,但如果不小心应用会很慢。对于您的情况,它们可能不会过多地压缩您的语法,因为无论如何您都需要输入这些名称,而这是笨重的部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-22
      • 1970-01-01
      • 2015-02-18
      • 1970-01-01
      • 2012-05-05
      • 1970-01-01
      相关资源
      最近更新 更多