How to use LIKE statement in sql plus with multiple wild carded values?

主宰稳场 提交于 2020-01-03 02:29:04

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4643409/how-to-use-like-statement-in-sql-plus-with-multiple-wild-carded-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!