I have an official table with id and name ....
Officials can have managers - they are stored in the connection table with the name officialupervisor with official_oid and supervisor_id as foreign keys to the official table.
I can show officials with my supervisor
SELECT o.official_name Official, p.official_name Supervisor FROM officialsupervisor s, official o, official p WHERE o.official_id = s.official_id AND p.official_id = s.supervisor_official_id
I can indicate officials who do not have a dispatcher with
SELECT o.official_name Official FROM official o WHERE o.official_id NOT IN (SELECT official_id FROM officialsupervisor)
But I canβt understand how to list all the officials with their leader, or empty if they donβt have them. It seems to me that this should be quite simple!
Thanks for any help.
source share