Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 using like with multiple items

Author  Topic 

csphard
Posting Yak Master

113 Posts

Posted - 2002-07-30 : 13:20:55
the following statement does not error off but it does not give me
the appropriate results. I know there is data because if i input
'09%' i will get the correct data. How do i get 01,03 and 04

data is
123456
010000
011235
092222
032222

this is the sequel statement

select empid from due_evals
WHERE empid
LIKE '[01%,03%,09%]'

whats wrong

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-30 : 13:23:42
You'd need to do:

select empid from due_evals
WHERE empid
LIKE '01%' OR empid LIKE '03%' OR empid LIKE '09%'


Or (sorry, just thought of this):

select empid from due_evals
WHERE empid
LIKE '0[139]%'


Edited by - robvolk on 07/30/2002 13:24:27
Go to Top of Page

csphard
Posting Yak Master

113 Posts

Posted - 2002-07-30 : 13:27:30
I saw this example LIKE '[a-cdf]' a, b, c, d, or f
but did not understand how that would work with out commas separating
them for instance LIKE '[a-c,d,f]'

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-30 : 13:38:13
Look in Books Online for more details on Like, there are several examples on how pattern matching works.

Go to Top of Page
   

- Advertisement -