存储过程,如何使用prepare连接字符串参数

写了一个存储过程:
create procedure jt1(title char(10))
begin
set @a=title;
prepare stmt from "select id from pro where ?";
execute stmt using @a;
end
这样调用:call jt1('name="wgh"');
最后输出:Empty set (0.00 sec),并没有得到想要的记录。
想到的执行等效这样的语句:select id from pro where name='wgh';
刚学习mysql不知道这样的效果应该怎么实现,哪个大侠帮忙指导一下,谢谢!

作者: 项仲   发布时间: 2011-07-16

create procedure jt2(title varchar(100))
begin
declare c varchar(200);
set c=concat('select id from pro where ',title);
set @a=c;
select @a;
prepare stmt from @a;
execute stmt;
end//

自己解决了。

作者: 项仲   发布时间: 2011-07-16