[b]奖励条目表 award_item:[/b]
[img]http://dl.iteye.com/upload/attachment/455453/94abfdf1-2e29-3453-a593-39807a601731.png[/img]
[b]注册记录表 award_reg_record:[/b]
[img]http://dl.iteye.com/upload/attachment/455455/5d6fabff-1ceb-35a6-86c4-80aae900931c.png[/img]
[b]领取奖品记录表 award_get_record:[/b]
[img]http://dl.iteye.com/upload/attachment/455457/e947d8f9-b165-3e68-97e3-ead48e27ab4c.png[/img]
统计某个任务下满足了领奖条件,但未领奖的人列表及其邀请的好友人数:
[b]not exist方式效率高:[/b]
[b]not in 方式效率低:[/b]
两种方式的执行结果是一样的:
[img]http://dl.iteye.com/upload/attachment/455461/ccf0ec09-9d7e-38f9-892b-6ff7dfad991d.png[/img]
[img]http://dl.iteye.com/upload/attachment/455453/94abfdf1-2e29-3453-a593-39807a601731.png[/img]
[b]注册记录表 award_reg_record:[/b]
[img]http://dl.iteye.com/upload/attachment/455455/5d6fabff-1ceb-35a6-86c4-80aae900931c.png[/img]
[b]领取奖品记录表 award_get_record:[/b]
[img]http://dl.iteye.com/upload/attachment/455457/e947d8f9-b165-3e68-97e3-ead48e27ab4c.png[/img]
统计某个任务下满足了领奖条件,但未领奖的人列表及其邀请的好友人数:
[b]not exist方式效率高:[/b]
select user_id, count(new_user_id) from award_reg_record arr
where 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_id
having count(*) > 5
[b]not in 方式效率低:[/b]
select user_id, count(new_user_id) from award_reg_record arr
where user_id not in (select user_id from award_get_record agr where agr.item_id=101)
group by user_id
having count(*) > 5
两种方式的执行结果是一样的:
[img]http://dl.iteye.com/upload/attachment/455461/ccf0ec09-9d7e-38f9-892b-6ff7dfad991d.png[/img]