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 ;
mysql存储过程
最新推荐文章于 2024-10-02 12:42:27 发布