Skip to content
Advertisement

How to use a variable with multiple values as a parameter in the where clause sql

I am trying to create a “where clause” that can handle multi-valued parameter but not getting it to work.

With the above sample table I wish to create a query that filters the rows with colors red and blue using a variable parameter like the following:

I tried using the STRING_SPLIT function but didn’t get it to work (result output is empty)

If remove the Blue from the Variable and only pass “Red” it works create but not when I try to pass multiple values.

Advertisement

Answer

You can use IN:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement