Discussion Locked

How to find multiple items with wildcards in SQL

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi! I'm pretty new to the SQL stuff - this is what I'm trying to do:

WHERE: Customer Name = "Romanow%" or "BCS%" or "%anse c%"

I know that that's not the correct way to write it... because I've tried a million different ways. Any suggestions? :)

Thanks, Tricia :)

2 replies

by cogstuff

you are nearly there -- use LIKE

EG

WHERE CustomerName Like ('%romanmow%') or CustomerName Like ('BCS%')

by tony hopkinson

Wild cards are
% for anything
_ (undersore) for a single character
There is also option
Where [Customer Name] Like '_[B,C,D]%' would find all customers where the 2nd character of their name was B,C or D.
Don't go mad with it though, it's not very fast.
Watch for case sensitivity as well it was insensitive by default last time I looked.

P.S. was the space in Customer name a typo, if not remember to wrap it in either square brackets or double quotes, deopending on waht server you use. Double quotes should work in any.

This discussion is closed to new replies.