您好我试图将以下内容从oracle转换为Mysql,因为Mysql不支持使用INTERSECT。我试图做几次加入但仍然没有运气。 Oracle Query:
select DISTINCT company_name from employee
inner join works on
works.Lastname=employee.Lastname AND
works.Firstname=employee.Firstname AND
works.MidInitial=employee.MidInitial
where employee.city='New York'
INTERSECT
select DISTINCT company_name from employee
inner join works on
works.Lastname=employee.Lastname AND
works.Firstname=employee.Firstname AND
works.MidInitial=employee.MidInitial
where employee.city='Seattle'
谢谢!
答案 0 :(得分:0)
在您的情况下(所有行都是唯一的),以下方法应该有效:
SELECT x.company_name FROM
(select DISTINCT company_name from employee
inner join works on
works.Lastname=employee.Lastname AND
works.Firstname=employee.Firstname AND
works.MidInitial=employee.MidInitial
where employee.city='New York') x
INNER JOIN
(select DISTINCT company_name from employee
inner join works on
works.Lastname=employee.Lastname AND
works.Firstname=employee.Firstname AND
works.MidInitial=employee.MidInitial
where employee.city='Seattle') y
USING (company_name)