我需要将查询转换为postgresql。我确切地说这个查询适用于mysql。
UPDATE cache_implementation n
INNER JOIN cache_compared compared ON n.compared_id = compared.nid
LEFT JOIN cache_implementation ncp ON (compared.parent_id = ncp.compared_id AND n.feature_id = ncp.feature_id)
INNER JOIN cache_feature feature ON n.feature_id = feature.nid
LEFT JOIN cache_implementation nfp ON (feature.parent_id = nfp.feature_id AND n.compared_id = nfp.compared_id)
SET n.parent_through_compared_id = ncp.nid, n.parent_through_feature_id = nfp.nid
当我尝试执行它时,附近有语法错误 第2行:INNER JOIN cache_compared比较ON n.com ...
感谢您的帮助。
答案 0 :(得分:1)
尝试:
UPDATE cache_implementation
SET cache_implementation.parent_through_compared_id = ncp.nid,
cache_implementation.parent_through_feature_id = nfp.nid
FROM cache_implementation n
INNER JOIN cache_compared compared ON n.compared_id = compared.nid
LEFT JOIN cache_implementation ncp ON (compared.parent_id = ncp.compared_id AND n.feature_id = ncp.feature_id)
INNER JOIN cache_feature feature ON n.feature_id = feature.nid
LEFT JOIN cache_implementation nfp ON (feature.parent_id = nfp.feature_id AND n.compared_id = nfp.compared_id)
WHERE cache_implementation.compared_id = n.compared_id
AND cache_implementation.feature_id = n.feature_id;