读书人

存储过程单引号有关问题

发布时间: 2012-04-28 11:49:53 作者: rapoo

存储过程,单引号问题
请教个问题,存储过程中参数,,IN stype VARCHAR(50)

我需要这样使用 where a in(stype) 它默认是 where a in ('1,2,3')
,我现在想要 where a in (1,2,3) 。。。。各位请问这样要怎么处理啊


[解决办法]
把要执行的sql拼成一个字符串,再prepare执行。
[解决办法]
set @asql=concat('select ... from ... where a in(\'',type,'\')');
prepare stml from @asql;
execute stml;
[解决办法]
where find_in_set(a,'1,2,3')
[解决办法]
where find_in_set(a,stype)

读书人网 >Mysql

热点推荐