Link to home
Create AccountLog in
Avatar of booneball
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
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

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
ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer