当我尝试连接具有内部连接的表时..返回数据..但是当我连接4个表与完全外连接时,我说
错误:仅在合并可加入的连接条件“
支持FULL JOIN
示例查询:
SELECT hr_employee.name,hr_movement.amount,hr_concept.name,hr_period.name
FROM hr_employee
FULL OUTER JOIN hr_movement
ON hr_employee.ad_client_id=hr_movement.ad_client_id
FULL OUTER JOIN hr_concept
ON hr_movement.ad_client_id=hr_employee.ad_client_id
FULL OUTER JOIN hr_period
ON hr_concept.ad_client_id=hr_employee.ad_client_id
答案 0 :(得分:1)
SELECT hr_employee.name,hr_movement.amount,hr_concept.name,hr_period.name
FROM hr_employee
FULL OUTER JOIN hr_movement
ON hr_employee.ad_client_id=hr_movement.ad_client_id
FULL OUTER JOIN hr_concept
ON hr_movement.ad_client_id=hr_employee.ad_client_id /*<- here*/
FULL OUTER JOIN hr_period
ON hr_concept.ad_client_id=hr_employee.ad_client_id /*<- and here*/
您正在加入表,但不要在连接条件中使用这些表。除此之外,MySQL不支持FULL OUTER JOINs
。他们像在this answer中一样实现。
答案 1 :(得分:0)
MySQL中没有FULL OUTER JOIN
。请参阅7.2.12. Outer Join Simplification和12.2.8.1. JOIN Syntax:
您可以使用模仿
FULL OUTER JOIN
UNION(来自MySQL 4.0.0):有两个表t1,t2:
SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id UNION SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id
有三个表t1,t2,t3:
SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id LEFT JOIN t3 ON t2.id = t3.id UNION SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id LEFT JOIN t3 ON t2.id = t3.id UNION SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id RIGHT JOIN t3 ON t2.id = t3.id
查看here