Joining 3 tables - doing joins how to
Posted
by Kieran
on Stack Overflow
See other posts from Stack Overflow
or by Kieran
Published on 2010-06-15T05:08:55Z
Indexed on
2010/06/15
5:12 UTC
Read the original article
Hit count: 214
This is my current query - its not getting the required result. I want it do display all of the "resources" even if they dont have a connection.
SELECT *
FROM (`user_permissions`)
JOIN `user_groups` ON `user_groups`.`id` = `user_permissions`.`role`
JOIN `user_resources` ON `user_resources`.`id` = `user_permissions`.`resource`
WHERE `role` = '4'
When I try left join or right join it still returns the same result. The result I get is:
id | role | resource | name
5 | 4 | 2 | Changelog
I want
id | role | resource | name
5 | 4 | 2 | Changelog
null | null | null | Resource2
null | null | null | Resource3
Is this possible?
© Stack Overflow or respective owner