日期:2014-05-16  浏览次数:20668 次

mysql 存储过程求解
table
id name number
1 fdfdfd 3223
2 dfdfdf 4566
存过程如下:
create procedure Ptest(in id int)
begin
select * from table where id=id;
end;//
此过程,就是依id号,显示信息,没有错语,我要改进一下。
安给的id来,称王筛选一下信息:
我要实现安name一列group by 应该怎么写
SQL code
create procedure Ptest2(in id int,in Paixu varchar(20))
begin
select * from table where id=id group by Paixu;
end;//

以上2问题错在何处?
就是,那个变量要怎么处理
select * from table where id=id group by Paixu;
还是这样:
select * from table where id=id group by '.Paixu.';

------解决方案--------------------
先你要理解一下group by 的用法!group by 是不能这样用的
------解决方案--------------------
select id,name from table 
group by name