How to use the LIKE statement correctly in a MySql SELECT statement?
Question
Why isn't this working?
DELIMITER ;//
CREATE PROCEDURE `blah`
(
SearchText varchar(4000)
)
BEGIN
SELECT *
FROM table_name
WHERE table_name.StringField LIKE '%' + SearchText + '%'; -- This is where the code is breaking
END;//
Solution
Try using:
CONCAT('%', SearchText ,'%')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow