Skip to content

Commit 4a539ff

Browse files
committed
join优化
1 parent 11c7c20 commit 4a539ff

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mysql开发技巧一/join优化

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@ select a.user_name , a.over , b.over from user1 a left join user2 b on a.user_na
8686

8787

8888

89-
89+
********************************************************************************
90+
使用join + having优化聚合子查询:
91+
select a.user_name,b.timestr,b.kills from user1 a join user_kills b on a.id = b.user_id
92+
join user_kills c on c.user_id = b.user_id
93+
group by a.user_name,btimestr,b.kills
94+
having b.kills = max(c.kills);
9095

9196

9297

0 commit comments

Comments
 (0)