Skip to content

Dynamic Like Statement in SQL

I’ve been racking my brain on how to do this for a while, and i know that some genius on this site will have the answer. Basically i’m trying to do this:

for a list of search strings stored in a column of a table. Obviously I can’t do a like statement for each string by hand because i want the table to be dynamic.

Any suggestions would be great. 😀

EDIT:

I’m using MSSQL 🙁

Advertisement

Answer

Put the parameters (string1, string2, string3…) into a table (Params) then JOIN to the table using LIKE the JOIN clause e.g.

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