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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -