问题
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