0
作为存储过程,这应该相当容易,但它并不是这种方式。两个输入:cname(概念名称,概念表)和vname(变量或列名称,评级表)。 cname输入工作的很好,但是当我输入vname时,我所得到的就是输入文本。因此,如果我“调用enc2.sptest('jello','dwb');”我会找回所有带有'jello'(cname)这个词的东西,但是我不会回到'dwb'(vname)这个列中的值。 MySQL可以接受列名输入吗?有解决方法吗?在存储过程中调用列名称
drop procedure if exists enc2.sptest;
delimiter $$
create procedure enc2.sptest (in cname varchar(1000),in vname text)
begin
select
a.concept_id
,a.concept_name
,b.vname
from enc2.concept a,enc2.ratings b
where a.concept_name like concat('%',cname,'%')
and vname is not null
and a.concept_id=b.concept_id
order by vname asc;
end
的[使用表名称的变量在MySQL存储过程]可能重复(http://stackoverflow.com/questions/2754423/use- a-variable-for-table-name-in-mysql-sproc) – 2012-02-14 18:04:11
感谢您的链接迈克尔,解决了它。 – user1185787 2012-02-14 21:20:20