Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 完全联接不工作_Mysql_Sql_Join_Myisam - Fatal编程技术网

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这行不通..检查第二个代码编写