How do I create a mysql LIKE variable? [closed]
-
03-07-2021 - |
Question
Is it possible to create a variable in MySql for a LIKE expression?
ex.
SET @test = '%my text to look for%';
SELECT * FROM MYTABLE WHERE MYCOLUMN LIKE @test;
Of course I tried this approach and it did not work.
Sorry for choosing the mysql-connect tag, couldn't really come up with anything else.
EDIT 1
"Did not work" means I don't get results with the variable as without.
Solution
Yes, your example should work fine. See my test case below:
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow