首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

约请好友注册满足条件可获得奖品:统计领奖情况

2012-09-07 
邀请好友注册满足条件可获得奖品:统计领奖情况奖励条目表 award_item:注册记录表 award_reg_record:领取奖

邀请好友注册满足条件可获得奖品:统计领奖情况
奖励条目表 award_item:



注册记录表 award_reg_record:



领取奖品记录表 award_get_record:




统计某个任务下满足了领奖条件,但未领奖的人列表及其邀请的好友人数:
not exist方式效率高:

select user_id, count(new_user_id) from award_reg_record arrwhere not exists (select user_id from award_get_record agr where agr.user_id=arr.user_id and agr.item_id=101)group by user_idhaving count(*) > 5

not in 方式效率低:
select user_id, count(new_user_id) from award_reg_record arrwhere user_id not in (select user_id from award_get_record agr where agr.item_id=101)group by user_idhaving count(*) > 5


两种方式的执行结果是一样的:


热点排行