문제

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.

도움이 되었습니까?

해결책

Yes, your example should work fine. See my test case below:

SQL Fiddle Example

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top