如何在sql plus中使用带有多个通配符值的LIKE语句?
我的问题是,目前如果我想查询多个通配符值。我需要做这样的事情。
select customername from customers where customername like '%smith' or customername like '%potter' or customer name like '%harris' or customername like '%williams';
所以想请教各位高手,有没有更简单的方法呢?
问候, 桑詹
my question is that currently if i want to query for multiple wildcarded values. I need to do something like this.
select customername from customers where customername like '%smith' or customername like '%potter' or customer name like '%harris' or customername like '%williams';
So I wanna ask from the experts, is there any easier way to do this?
Regards,
Sanjan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建一个包含 100 个姓名的表
select customername fromcustomers c inside joincustomersames cn on(c.customernamename like '%'+cn.searchForname)
如果有帮助,可以是表变量。
Create a table of your 100 names
select customername from customers c inner join customersames cn on(c.customernamename like '%'+cn.searchForname)
Can be a table variable if that helps.
您可以使用正则表达式
编辑:您可以在网上找到大量资源。以 http://66.221.222.85/reference/regexp.html 为例。
正则表达式确实很强大,但如果应用不小心,可能会非常慢。对于您的情况,它们可能不会对您的语法造成太大压力,因为您无论如何都需要输入这些名称,而这是庞大的部分。
you can use regular expressions
EDIT: You can find plenty of resources online. take http://66.221.222.85/reference/regexp.html for example.
Regular expressions are really powerful but can be very SLOW if applied carelessly. For your case they may not squeeze your syntax much because you need to type those names anyway and that's the bulky part.