顯示部門與上層部門 中文名稱 (SQL 查詢 虛擬表 + LEFT JOIN)(同一資料表變成兩份資料使用JOIN整合查詢)
顯示部門與上層部門 中文名稱 (SQL 查詢 虛擬表 + LEFT JOIN)(同一資料表變成兩份資料使用JOIN整合查詢)
虛擬表 :
(SELECT id,name FROM department) AS above
完整語法 :
SELECT dep.name AS department_name,above.name AS above_department_name FROM department AS dep LEFT JOIN (SELECT id,name FROM department) AS above ON dep.unit=above.id