tags:

views:

33

answers:

1

I have a table in MSSQL that has several columns. It looks as follows:

col1| col2 | col3
------------------
HSP | full | ""
HSP | full | "UE"
HSP | min | ""
HSP | min | "PS"
CC | full | "UE"

My select query has 2 parameters, which receives from web app:

@col2 = { full, min }
@col3 = e.g. "PE+UE+STR" or "PE" or "" (in general - combination of different abbreviations or none)

All i want to do is to select only those rows, which contain the appropriate abbreviation. e.g. if the input is
@col2 = "full"
@col3 = "PE+UE+STR"

output:
HSP | full | "UE"
CC | full | "UE"

if @col3 = "", the output would be:
HSP | full | ""
HSP | min | ""

Thanks for any help.
Marcin

A: 

Now I might be totally off, but I remember there being a LIKE keyword in SQL.

SELECT * from table WHERE col3 LIKE pattern

where pattern is what you want to compare with. You might need to parse the parameter to convert into .... WHERE col3 LIKE pattern1 OR col3 LIKE pattern2 or something perhaps?

If this is totally off, please comment.

villintehaspam
You're right. In DAL, I should convert the @col3 parameter to an array and use WHERE, LIKE, OR.Thanks!
Marcin