SQL加入四个表

时间:2017-01-12 19:08:55

标签: sql

显示员工姓名,工资以及他们为未在意大利运营部门工作的IT开发人员所工作的城市名称

我做了这个并且没有用

SELECT e.first_name, e.last_name, e.salary, l.city
FROM employees e
JOIN jobs j
    ON (j.job_id = e.job_id)
WHERE
    AND e.commission_pct = 0
    AND job_title LIKE '%IT Developer%'
JOIN locations l
    ON (l.location_id = d.location_id)
        AND 
        (
            l.country LIKE '%Italy%'
            AND 
            department_name = 'Operations'
        );

http://imgur.com/lex2SyV这是我的逻辑ERD的链接

1 个答案:

答案 0 :(得分:0)

SELECT e.first_name,e.last_name,e.salary,l.city
FROM employees e join jobs j
ON(j.job_id = e.job_id)
join departments d ON (d.department_id=e.department_id)
join locations l 
ON (l.location_id = d.location_id)

WHERE e.commission_pct = 0 AND 
job_title LIKE '%IT Developer%'

AND (l.country LIKE '%Italy%'
AND d.department_name = 'Operations')