Mysql 完全联接不工作
这是我的 我的问题是:Mysql 完全联接不工作,mysql,sql,join,myisam,Mysql,Sql,Join,Myisam,这是我的 我的问题是: select employee.eid, staff.acc_no from employee FULL JOIN staff on employee.eid = staff.eid 我可以做连接,左连接,右连接,但不能完全连接。上面说的是错误 Unknown column 'employee.eid' in 'field list': select employee.eid, staff.acc_no from employee FULL JOIN staff on
select employee.eid, staff.acc_no from employee FULL JOIN staff on employee.eid = staff.eid
我可以做连接,左连接,右连接,但不能完全连接。上面说的是错误
Unknown column 'employee.eid' in 'field list': select employee.eid, staff.acc_no from employee FULL JOIN staff on employee.eid = staff.eid
我犯了什么错误?正如@Niels首先指出的那样,mysql中没有完全连接 我建议你读书 但是,您可以在
联合
操作符的帮助下模拟外部联接
详细解释也可以找到MySQL不支持
完全外部连接
。但是,您的表应该具有适当的外键关系,因此不需要:
select employee.eid, staff.acc_no
from employee INNER JOIN
staff
on employee.eid = staff.eid;
如果没有,您可以使用union all
/group by
方法:
select eid, max(accno) as accno
from (select e.eid, NULL as acc_no from employee e union all
select s.eid, s.acc_no from staff
) se
group by eid;
查看@Neils的可能副本谢谢我收到了!太棒了,另一种方式+1@gordonLinoff这行不通..检查第二个代码编写