【发布时间】:2018-01-14 18:21:03
【问题描述】:
我的目标是结合两个表(predictions 和 user_score)的结果,这样我就拥有了所有在比赛中得分和没有得分但正在参与池的用户 (poolid=110)
预测
predid | matchid | ueserid | points |
--------------------------------------------
1 121 8 1
2 122 8 2
3 122 10 3
user_score
id | poolid | userid |
------------------------------
1 110 8
2 110 10
3 111 8
4 111 10
结果应该是这样的:
| matchid | ueserid | points | poolid
--------------------------------------------
121 8 1 110
null 10 null 110
这是我尝试过的几个查询:
SELECT * FROM predictions LEFT JOIN user_score on predictions.userid = user_score.userid WHERE predictions.matchid=121 and user_score.poolid=110
SELECT * FROM predictions RIGHT JOIN user_score on predictions.userid = user_score.userid WHERE predictions.matchid=121 and user_score.poolid=110
此查询不适用于我的 SQL 版本 Apache/2.4.26 (Win32) OpenSSL/1.0.2l PHP/5.6.31 / 数据库客户端版本:libmysql - mysqlnd 5.0.11-dev - 20120503 /
SELECT * FROM predictions FULL OUTER JOIN user_score on predictions.userid = user_score.userid WHERE predictions.matchid=121 and user_score.poolid=110
我需要帮助:)
【问题讨论】:
-
MySQL 不支持 FULL OUTER JOIN