日期:2014-05-16 浏览次数:20813 次
CREATE PROCEDURE `myTest`(v_str1 varchar(200)) BEGIN select v_str1; select * from table where FIND_IN_SET(str1,v_str1) END;
------解决方案--------------------
1、用动态语句执行
declare stmt varchar(4000);
set @v_sql = concat('select * from tt where str1 in (', i_param,')');
prepare stmt from @v_sql;
execute stmt;
2、用FIND_IN_SET OR INSTR函数
select * from table where FIND_IN_SET(str1,v_str1)
select * from table where instr(str1,v_str1)
------解决方案--------------------
set @sql=concat='select IFNULL(str1,'') from table';
你的语法也错得太多了吧。
set @sql=concat('select IFNULL(str1,\'\') from table');
------解决方案--------------------
set @sql=concat('select IFNULL(str1,\'\ ') from table');
用两个空格 OR * 均可