I'm trying to get values from three tables even if one is empty.
Since I would be able to use an if else statement depending if the following.follow_id
row is empty or not.
SELECT user.id, user.username,user.email, userdetails.profile_img, following.follow_id
FROM user
JOIN userdetails ON user.id = userdetails.user_id
JOIN following ON user.id = following.follow_id
GROUP BY user.id;
For now it only gives me the value if there is a value on row following.follow_id
.
But I would be able to get all the result from the user_id even if there's an empty table.
Any clues ?
Replacing "JOIN", which implies "INNER JOIN", by "LEFT JOIN" should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With