Dotazy nad více tabulkami - možné řešení

From Wikivyuka
Jump to: navigation, search

Dotazy nad více tabulkami

  1. DESC employees; DESC departments;
  2. SELECT * FROM EMPLOYEES, DEPARTMENTS;
  3. SELECT e.employee_id, e.department_id, d.department_id, d.department_name FROM EMPLOYEES e, DEPARTMENTS d;
  4. SELECT e.employee_id, e.department_id, d.department_id, d.department_name FROM EMPLOYEES e, DEPARTMENTS d WHERE e.department_id=d.department_id; Varianta dle SQL1999: SELECT employees.employee_id, department_id FROM employees JOIN departments ON (e.department_id=d.department_id) ;
  5. SELECT department_id, department_name, city FROM departments d JOIN locations l ON (l.location_id = d.location_id);
  6. SELECT e.employee_id, e.first_name, e.last_name, e.commission_pct, d.department_name FROM employees e JOIN departments d ON (e.department_id = d.department_id) WHERE d.department_name='Sales';
  7. SELECT e.last_name emp, m.last_name mgr FROM employees e JOIN employees m ON (e.manager_id = m.employee_id) order by m.last_name;

Dotazy nad více tabulkami

Hlavní stránka předmětu