读书人

mysql 存储过程求解,该如何解决

发布时间: 2012-06-14 16:00:31 作者: rapoo

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))beginselect * 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

读书人网 >Mysql

热点推荐