We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0b329e1 commit 497eeadCopy full SHA for 497eead
mysql开发技巧三/如何在子查询中匹配两个值
@@ -0,0 +1,18 @@
1
+**************************************************************************************************
2
+将子查询改为join写法时要注意表中关系是不是一对多或多对多,这种情况下要对查询结果使用distinct去重。
3
+
4
5
+select a.user_name,b.timestr,kills from user1 a join user_kills b on
6
+ a.id=b.user_id join(select user_id,max(kills) as cnt from user_kills group by user_id)c on
7
+ b.user_id=c.user_id and b.kills=c.cnt;
8
9
+mysql中独有的列过滤方式:多列过滤
10
+select a.user_name,b.timestr,kills
11
+from user1 a
12
+join user_kills b on a.id=b.user_id
13
+where (b.user_id,b.kills) in (
14
+ select user_id,max(kills)
15
+ from user_kills
16
+ group by user_id
17
+);
18
0 commit comments