Forum Moderators: open

Message Too Old, No Replies

SQL how to

         

shaan1980

9:38 pm on Mar 23, 2006 (gmt 0)

10+ Year Member



I want to search throught the database for multiple strings with wild characters

for example

select * from table where table.p in ('A%','B%')

queries like these don't work in sybase. Please advise

ChadSEO

9:48 pm on Mar 23, 2006 (gmt 0)

10+ Year Member



Something like this should work for you:

SELECT *
FROM table
WHERE table.p like 'A%' OR table.p like 'B%'

If you have other WHERE statements, you can group them, ala:

SELECT *
FROM table
WHERE table.field > 5 AND (table.p like 'A%' OR table.p like 'B%')

Chad

arran

10:17 pm on Mar 23, 2006 (gmt 0)

10+ Year Member



sybase

Hi shaan, I bet we're the only 2 Sybase users on this board!

arran.

syber

3:08 pm on Mar 24, 2006 (gmt 0)

10+ Year Member



You can do this:

select * from table where table.p like ('[AB]%')

shaan1980

6:54 pm on Mar 24, 2006 (gmt 0)

10+ Year Member



I went with CHADs response it seems to do the job
syber that doesn't seem to work really .
aaron are you serious?

shaan1980

6:55 pm on Mar 24, 2006 (gmt 0)

10+ Year Member



Thank you all for your responses it was much appreciated.

syber

7:15 pm on Mar 24, 2006 (gmt 0)

10+ Year Member



Don't know why that wouldn't work, it is standard ANSII SQL. Try it without the parens.

select * from table where table.p like '[AB]%'