小试创建存储过程

CREATE PROCEDURE `pr_sel`(   
in Input_uid int

)

创建存储过程的指令,括号内的是存储过程的参数定义,参数可以分为三类:


“in”、“out”、“inout”,则默认为“in”,习惯上,对于是“in” 的参数,都不会显式指定。


注:MySQL 存储过程参数,不能在参数名称前加“@”,如:“@a int”。


下面是执行的sql语句,需要从begin开始,end结束:



begin   



declare userid int; 


if userid is null then   
set userid = 0;   
end if;


set userid = Input_uid;   


/*查询该用户*/
select * from user where user_id=userid;


/*查询该用户的billing*/
select * from Billing where user_id=userid;


/*查询改用户的会议*/
select * from Conference where author_id=userid;


/*查询改用户Comment*/
select * from Comment where author_id=userid;


/*查询该用户的billing*/
select * from OauthInfo where uid=userid;


/*查询该用户的Feedback*/
select * from Feedback where uid=userid;


/*查询该用户的UserInventory*/
select * from UserInventory where user_id=userid;


/*查询该用户的Deposit*/
select * from Deposit where user_id=userid;


/*查询该用户的Invoice*/
select * from Invoice where user_id=userid;


/*查询该用户的Orders*/
select * from Orders where user_id=userid;


/*查询该用户的Transaction*/
select * from Transaction where user_id=userid;


end;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值