search - SQL query over multiple inputs -
i've got table containing number of text columns, , need able query table using search term. single terms, simple...
select * things @searchterm in (column1, column2...columnx)
however, need search on multiple terms in single query, like...
select * things @searchterms in (column1, column2...columnx)
...where @searchterms
collection of values, rather single value. there way emulate behaviour in sql?
update: thank @tedo g., unfortunately need query use and
between different terms. i've added change yours group results , ensure count per distinct result matches number of terms...
select * things inner join @searchterms b on b.[fieldname] in (column1, column2...columnx) group column1, column2...columnx having count(column1) = @numberofsearchterms
...this works, there better way?
one other way achieve make table variable , fill search term values, join :
select * things inner join @searchterms b on b.[fieldname] in (column1, column2...columnx)
Comments
Post a Comment