存储过程代码:
CREATE PROCEDURE so(IN mov char(255),IN p1 int,IN p2 int)   
BEGIN  
SET @sql = CONCAT('SELECT * FROM filedata where title like (%',mov,'%) order by dateandtime desc LIMIT ',p1,',',p2,'');   
PREPARE sqlstmt FROM @sql;   
EXECUTE sqlstmt;   
DEALLOCATE PREPARE sqlstmt;   
END$$当我调用这个存储过程call so('nba','1','2');,MYSQL提示出错:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%nba%) order by dateandtime desc LIMIT 1,2' at line 1希望各位高手能给指点下迷津,小弟不胜感激!

解决方案 »

  1.   

    SET @sql = CONCAT('SELECT * FROM filedata where title like (\'%',mov,'\'%) order by dateandtime desc LIMIT ',p1,',',p2,'');   
      

  2.   

    还是报错:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') order by dateandtime desc LIMIT 1,2' at line 1
      

  3.   

    SET @sql = CONCAT('SELECT * FROM filedata where title like \'%',mov,'%\' order by dateandtime desc LIMIT ',p1,',',p2,'');   
      

  4.   

    多谢 ACMAIN_CHM ,问题解决了 I love CSDN!hoho..