Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LIKE statement

Status
Not open for further replies.

sagn

Programmer
Jun 7, 2001
166
US
Hi,

Is there a way to use a list of strings with the
like statement?

For example I can do

select * from table
where
col1 like 'test%'
or col1 like 'fun%'
or col1 like 'sun%'

Is there any way to condense this to soemthing like

select * from table
where col1 like ('test%','fun%','sun%')


thanks
 
There are some wildcards you can use, but not exactly what your looking for.... for instance you could get the "fun" & "sun" with LIKE '[fs]un%' (See BOL for the wildcards....)

But if your items are a lot different (test & fun)....this doesn't really work well. IMHO - using these wildcards also makes the code, much less intuitive (I always have to stop and think....okay, what is this searching for?????)

But, I don't know of a way to do what you originally asked.... (w/ IN)

J. Jones
jjones@cybrtyme.com
 
I was hoping there would be something like there is with the
IN statement...


ds
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top