I have a sample data:
users(id, name)
1 | peter
...
usermeta(user_id, meta_key, meta_value)
1 | level | 10
1 | display | pc
...
points(user_id, type, point)
1 | like | 5
2 | comment| 10
...
And mysql:
SELECT u.*,
(case when m.meta_key = 'level' then m.meta_value end) level ,
p.points AS point
FROM users u
LEFT JOIN points p ON p.user_id = u.id
LEFT JOIN usermeta AS m ON m.user_id = u.id
Result level = NULL, how to fix it?
id | name | level | point
1 | peter| NULL | 5
1 | peter| 10 | 10