Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Simplifying WHERE column1=value1 AND column1= value2 filter

$
0
0

Hello,

I am trying to build a query that compares all values for a given column in "AND" operation.

DECLARE @param NVARCHAR(100
SET @param = '1,2,3,4,5'

SELECT * From Company

WHERE ID = 1 AND ID = 2 AND ID = 3...

I create a user defined Split function that returns a table after splitting the param but it only seems to work for "OR" operation:

WHERE ID IN (SELECT ID FROM Split(@param, ',').

Any suggestions would be greatly appreciated.

Thanks


SK


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>