`
hyl198611
  • 浏览: 225667 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

mysql存储过程

阅读更多

DELIMITER $$

DROP PROCEDURE IF EXISTS `lekan`.`QueryUserExtend` $$
CREATE DEFINER=`root`@`%` PROCEDURE `QueryUserExtend`(in p_userId  bigint,
out p_ticketNum int  ,out p_mood varchar(500) ,out p_avatarNum int,out p_theaterNum int,out p_collectNum int,out p_friendNum int,out p_badgeNum int,out p_userScoreNum int,out p_userCommentNum int,out p_userWatchNum int)
begin
select ticketNum,mood into p_ticketNum,p_mood  from user_extend where userId=p_userId;
select count(tranId)  into p_avatarNum from user_transformers where userId=p_userId and tranType=2;
select count(tranId)  into p_theaterNum from user_transformers where userId=p_userId and tranType=1;
select count(id) into  p_collectNum from user_collected_video where userId=p_userId;
select count(id) into p_friendNum from user_friend f,user u where f.userId=p_userId and f.friendId=u.userId;
select count(id) into p_badgeNum from user_badge where userId=p_userId;
select count(distinct(videoId)) into p_userScoreNum from user_video_score where userId=p_userId;
select count(vc.commentId) into p_userCommentNum from video v join video_comment vc where  vc.videoId=v.videoId and vc.parentId=0 and vc.userId =p_userId;
select count(videoId) into p_userWatchNum  from user_watched_video where  userId = p_userId;
end $$

DELIMITER ;

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics