Left join: Right number of rows, fields are null

I’m trying to execute the following query:

SELECT role_permissions.role as role, role_permissions.permission as permission_id, permissions.id as perm_id, permissions.description as perm_description
FROM `role_permissions`
LEFT JOIN `permissions` ON `role_permissions`.`role` = `permissions`.`id`
WHERE `role_permissions`.`role` = '1'

I get this result set:
role | permission_id | perm_id | perm_description
1 | 14 | NULL | NULL
1 | 16 | NULL | NULL

I am expecting to get:
role | permission_id |perm_id | perm_description
1 | 14 | 14 | viewOrganisaties
1 | 16 |16 | editOrganisaties

Ik krijg dus het juiste aantal rijen, alleen krijg ik om de een of andere reden geen waarden van permissions.id (perm_id) en permissions.description (perm_description) en ik kan maar niet uitvinden waarom niet… Ik hoop dat jullie een idee hebben?
So, I am getting the right number of rows, except for some reason the fields permissions.id (perm_id) en permissions.description (perm_description) get returned as NULL. I just can’t figure out why. Hopefully you guys can give me some insight?

Just had a major facepalm moment when somewhere else someone adviced me to change
LEFT JOIN permissions ON role_permissions.role = permissions.id

LEFT JOIN permissions ON role_permissions.permission = permissions.id

please share phpfiddle OR your database structure.

I have already solved it. I edited my post a few days ago and put the solution in the original post

Sponsor our Newsletter | Privacy Policy | Terms of Service