Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Join on 4 tables

Marclem

Technical User
Aug 5, 2003
94
US
Greetings,

I have below query which I am trying to get the last table named st_role column st_role.sf_name data but I am getting "null" values...

Basically sf_role_id PK is also at table st_useraccount_roles and tables st_user and st_useracount_roles have a matching PK named sf_user_id.

SELECT
st_user.sf_firstname as "First Name", st_user.sf_lastname as "Last Name", st_user.sf_emailaddress as "Email",
st_user.sf_username as "Username", date(st_user.sf_last_login) as "Last Login",
st_department.sf_name as "Workgroup",
(CASE WHEN st_user.sf_active = '1'::boolean THEN 'Enabled' WHEN st_user.sf_active = '0'::boolean THEN 'Disabled' END) as "Account Status",
st_role.sf_name
FROM
st_user
JOIN st_department on (st_user.sf_department_id = st_department.sf_id)
LEFT JOIN st_useraccount_roles on (st_user.sf_user_id = st_useraccount_roles.sf_user_id)

LEFT JOIN st_role on (st_useraccount_roles.sf_role_id = st_role.sf_role_id)
ORDER BY st_user.sf_firstname ASC

Thank you for your support!
 

Part and Inventory Search

Sponsor

Back
Top