How to search multiple columns for specific text

General

How to search multiple columns for specific text

Hello,  I have a table with multiple columns that display similar information and am trying to query multiple columns for a specific value.  for example the columns ID1, ID2 ID3

id1            id2       id 3        cm#

dl123        dl321    null            1

dl321         dl456   dl345         2

dl567         dl123    dl987        3

I am trying to get a result showing cm 1 and 3

any help is appreciated

4 REPLIES

Re: How to search multiple columns for specific text

Do you mean you want to write something like:

where cm# IN (1,3)

OR

Where Id1 = 'dl123' or id2 = 'dl321' or cm# IN (1,3)

Please clarify.

Khurram

Re: How to search multiple columns for specific text

I a m look for something like

where id1 or id2 or id3 = 'dl123'

Re: How to search multiple columns for specific text

To further clarify I have

Select

cm#

from cm_databse

where 'dl123' in (id1, id2, id3)

But I get a syntax error

Re: How to search multiple columns for specific text

try this:

Select
cm#
from cm_databse
where id1 = 'dl123' OR id2 = 'dl123' OR id3 = 'dl123'
Khurram