My goal to combine results from two tables (predictions and user_score) so that I have all users who scored the points in the match and who did not score the points, but are participating in the pool (poolid=110)
predictions
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
Results should be like that:
| matchid | ueserid | points | poolid
--------------------------------------------
121 8 1 110
null 10 null 110
This is few queries that i tried:
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
This query doesnt work on my SQL version Apache/2.4.26 (Win32) OpenSSL/1.0.2l PHP/5.6.31 / Database client version: 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
I need help :)