This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
kurs:joins [2010/04/16 13:36] mh |
kurs:joins [2020/05/12 10:09] admin |
||
---|---|---|---|
Line 41: | Line 41: | ||
e.employee_id(+) = m.manager_id | e.employee_id(+) = m.manager_id | ||
order by m.employee_id | order by m.employee_id | ||
+ | |||
+ | SELECT EMPLOYEES.FIRST_NAME, | ||
+ | EMPLOYEES.LAST_NAME, | ||
+ | MANAGER.FIRST_NAME "MANAGER FIRST_NAME", | ||
+ | MANAGER.LAST_NAME "MANAGER LAST_NAME" | ||
+ | FROM HR.EMPLOYEES right join EMPLOYEES MANAGER | ||
+ | on ( (EMPLOYEES.MANAGER_ID = MANAGER.EMPLOYEE_ID) ) | ||
+ | where employees.employee_id is null | ||
+ | (89 rows) | ||
+ | |||
+ | </code> | ||
+ | |||
+ | Join über mehrere Tabellen hinweg | ||
+ | <code> | ||
+ | SELECT | ||
+ | first_name, | ||
+ | last_name, | ||
+ | coalesce(department_name, '[kein department]'), | ||
+ | city, | ||
+ | country_name, | ||
+ | region_name | ||
+ | FROM | ||
+ | hr.employees | ||
+ | left JOIN hr.departments ON employees.department_id = departments.department_id | ||
+ | left join hr.locations on departments.location_id = locations.location_id | ||
+ | left join hr.countries on locations.country_id = countries.country_id | ||
+ | left join hr.regions on countries.region_id = regions.region_id | ||
+ | where region_name = 'Europe' | ||
+ | </code> | ||
+ | |||
+ | <code> | ||
+ | SELECT | ||
+ | first_name, | ||
+ | last_name, | ||
+ | e.department_id aktuelle_department_id, | ||
+ | jh.department_id jh_department_id, | ||
+ | e.job_id aktuelle_job_id, | ||
+ | jh.job_id jh_job_id, | ||
+ | start_date, | ||
+ | end_date | ||
+ | FROM | ||
+ | employees e left JOIN job_history jh | ||
+ | ON e.employee_id = jh.employee_id | ||
+ | ORDER BY | ||
+ | coalesce(e.employee_id, jh.employee_id) | ||
</code> | </code> |