【发布时间】:2017-11-21 05:21:44
【问题描述】:
尝试用这样的 OR 条件连接 2 个表:
FULL JOIN table1
ON (replace(split_part(table1.contract_award_number::text, ' '::text, 2), '-'::text, ''::text)) = table2.contract_award_id
OR (btrim(replace(table1.solicitation_number::text, '-'::text, ''::text))) = table2.solicitation_id
但是 Postgresql 对我咆哮:
FULL JOIN is only supported with merge-joinable or hash-joinable join conditions
什么给了?出于某种原因,如果我添加条件:
WHERE table1.solicitation_number::text ~~ '%%'::text
错误没有发生,但我怀疑这会破坏 FULL JOIN 结果。
感谢您的帮助。
【问题讨论】:
-
可以将完全外连接模拟为两个连接的联合。
-
hmm 有趣...这不会忽略不加入的结果吗?
-
如果您发布完整的查询,我可以给您一个解决方法。
-
SELECT column1, column2, column3 FROM fpds_opportunities fpds FULL JOIN fbo_all_opportunity_detail fbo ON replace(split_part(fbo.contract_award_number::text, ' '::text, 2), '-'::text, ' '::text) = fpds.contract_award_id OR btrim(replace(fbo.solicitation_number::text, '-'::text, ''::text)) = fpds.solicitation_id WHERE AND (fpds.base_and_all_options_value::numeric > 20000 ::numeric OR fpds.base_and_all_options_value 为 NULL);
标签: postgresql join