我有三张桌子
table_4
table_5
table_6
每个表都有不同的数据片段。
我想要创建一个大表,将所有可能的数据连接起来(一个人在1和3个表中,第二个人在2个表中等等)--并且希望将它合并到一个大表中,比如。
效果很好,但是
SELECT
*
FROM
table_4
FULL JOIN
table_5
ON
table_5_field_s_mail_dmp_id =table_4_field_email_dmp_id
FULL JOIN
table_6
ON
table_6_field_phone2_dmp_id =table_4_field_phone_dmp_id
OR table_6_field_phone1_dmp_id =table_4_field_phone_dmp_id
OR table_6_field_workphone_dmp_id =table_4_field_phone_dmp_id
OR table_6_field_addphone_dmp_id =table_4_field_phone_dmp_id
OR table_6_field_email_dmp_id =table_5_field_s_mail_dmp_id
OR table_6_field_email_dmp_id =table_4_field_email_dmp_id 返回
错误:如果没有连接两侧字段相等的条件,则不能使用完全外部联接。
我无法克服这个错误和如何解决我的问题
又说我查过
SELECT
*
FROM
table_4
FULL JOIN
table_6
ON
(table_6_field_phone2_dmp_id =table_4_field_phone_dmp_id
OR table_6_field_phone1_dmp_id =table_4_field_phone_dmp_id
)它也会返回同样的错误。大查询不喜欢还是在完全连接条件下?
发布于 2018-03-06 12:55:27
编写单独的查询,然后使用COALESCE。(发帖a nice example的Ajit是功劳。)
https://stackoverflow.com/questions/49073352
复制相似问题