User Tools

Site Tools


kurs:joins

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
kurs:joins [2014/09/10 21:22]
127.0.0.1 external edit
kurs:joins [2020/05/12 10:09] (current)
admin
Line 52: Line 52:
  
  
 +</​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>​
kurs/joins.1410376975.txt.gz · Last modified: 2014/09/10 21:22 by 127.0.0.1