I’m trying to join 3 tables that hold values for users – their id and username, and table engine4_storage_files that has info about users profile picture. If user hasn’t uploaded it’s profile pic, there isn’t a record in sf table – but I want to query all users regardless of weather the pic is uploaded or not.
SELECT p.user_id as gledalac, sf.storage_path,
u.displayname, u.username
FROM engine4_pregledi p JOIN
engine4_storage_files sf JOIN
engine4_users u
WHERE p.subject_id = 1
AND p.user_id = u.user_id
AND sf.parent_id = u.user_id
AND sf.parent_type = 'user'
AND sf.type = 'thumb.icon'
AND sf.parent_file_id = u.photo_id
order by datum desc limit 10
This query returns 3 users with path to their images, but actually there are 4 users to be shown, but 4th user doesn’t have profile image – so he’s not included in query result.
Is there a way to include 4th user that doesn’t have profile image into query results?
use
LEFT JOINinstead,To fully gain knowledge about joins, kindly visit the link below: