booneball
asked on
SQL Joins
For some reason the query below is only returning results where there is an entry in every table with the user id. I want it to display every user whether they are associated with a system or not.
SELECT s.client_name, s.company, u.name AS emp, p.extension
FROM joomla.jos_users u JOIN it.system s
ON u.id = s.user JOIN joomla.user_profile p
ON s.user = p.id
Many Thanks
SELECT s.client_name, s.company, u.name AS emp, p.extension
FROM joomla.jos_users u JOIN it.system s
ON u.id = s.user JOIN joomla.user_profile p
ON s.user = p.id
Many Thanks
Use LEFT JOIN instead
SELECT s.client_name, s.company, u.name AS emp, p.extension
FROM joomla.jos_users u LEFT OUTER JOIN it.system s
ON u.id = s.user JOIN joomla.user_profile p
ON s.user = p.id
FROM joomla.jos_users u LEFT OUTER JOIN it.system s
ON u.id = s.user JOIN joomla.user_profile p
ON s.user = p.id
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.