All Forums General
txrob74 4 posts Joined 11/15
25 Jul 2016
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
 

M.Saeed Khurram 544 posts Joined 09/12
26 Jul 2016

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

txrob74 4 posts Joined 11/15
26 Jul 2016

I a m look for something like
where id1 or id2 or id3 = 'dl123'

txrob74 4 posts Joined 11/15
26 Jul 2016

To further clarify I have
 
Select
cm#
from cm_databse
where 'dl123' in (id1, id2, id3)
 
But I get a syntax error
 
 

M.Saeed Khurram 544 posts Joined 09/12
27 Jul 2016

try this:

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

 

Khurram

You must sign in to leave a comment.