views:

183

answers:

1

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;//
+4  A: 

Try using CONCAT('%', SearchText ,'%')

Ryan Oberoi
+1 MySQL does not support "+" as a string concatenation operator. That's a Microsoft/Sybase thing.
Bill Karwin
Indeed. The SQL standard also defines the || operator for character string (and bit string) concatenation, which is the way I'm used to seeing it done.
cheduardo
Awesome. Yeah I come from a MSSQL background so I kind of take that for granted. Once I'm finished with this project, I'm going to create a wiki entry "Top 20 things you should know when converting MSSQL to MySQL"
DJTripleThreat