定义的MySQL存储过程如下:
DELIMITER $$CREATE  PROCEDURE `p_test`(id int)
BEGIN
    select * from test where id = id;
END然后调用此存储过程,call p_test(1);结果表中将所有的数据全部查找出来
什么原因,求助

解决方案 »

  1.   

    注意变量名与字段名不要重名,默认字段名
    DELIMITER $$ CREATE  PROCEDURE `p_test`(aid int)
     BEGIN
         select * from test where id = aid;
     END
      

  2.   

    select * from test where id = id;
    这个相当于没where条件了  改成变量改成id1  where id=id1
      

  3.   

    变量和字段重复造成的
    Delimiter$$
    create procedure `P_test`(cid int)
    begin
         select * from test where id=cid;
    end
      

  4.   

    MySQL是不是不区分大小写,我将参数id设置为大写,即ID,仍然无法使用