用 with 拼接三个 CALL apoc.load.jdbc 语句,无法出结果
发布于 1 个月前 作者 godsdusk 176 次浏览 来自 问答

顺序执行以下三个语句是正常的

CALL apoc.load.jdbc('jdbc:mysql://localhost/wechat?user=root&password=root@&useUnicode=true&characterEncoding=utf8','select * from keyword')YIELD row
CALL apoc.merge.node([row.label], {name:row.keyword}) YIELD node
return node

CALL apoc.load.jdbc('jdbc:mysql://localhost/wechat?user=root&password=root@&useUnicode=true&characterEncoding=utf8','select * from shop')YIELD row 
CALL apoc.merge.node(['商品'], {name:row.title}) YIELD node
MATCH (m) WHERE m.name IN split(row.keywords, ',') AND labels(m) <> ['商品']  MERGE p=(m)-[:关键字]-(node) RETURN p

CALL apoc.load.jdbc('jdbc:mysql://localhost/wechat?user=root&password=root@&useUnicode=true&characterEncoding=utf8','select * from article')YIELD row 
CALL apoc.merge.node(['文章'], {name:row.title}) YIELD node
MATCH (m) WHERE m.name IN split(row.keywords, ',') AND labels(m) <> ['文章'] MERGE p=(m)-[:关键字]-(node) RETURN p

但是用 with 拼接起来执行,就在那一直转圈出不来结果

CALL apoc.load.jdbc('jdbc:mysql://localhost/wechat?user=root&password=root@&useUnicode=true&characterEncoding=utf8','select * from keyword')YIELD row
CALL apoc.merge.node([row.label], {name:row.keyword}) YIELD node as n1
with n1
CALL apoc.load.jdbc('jdbc:mysql://localhost/wechat?user=root&password=root@&useUnicode=true&characterEncoding=utf8','select * from shop')YIELD row 
CALL apoc.merge.node(['商品'], {name:row.title}) YIELD node as n2
MATCH (m) WHERE m.name IN split(row.keywords, ',') AND labels(m) <> ['商品']  MERGE p1=(m)-[:关键字]-(n2) with p1
CALL apoc.load.jdbc('jdbc:mysql://localhost/wechat?user=root&password=root@&useUnicode=true&characterEncoding=utf8','select * from article')YIELD row 
CALL apoc.merge.node(['文章'], {name:row.title}) YIELD node as n3
MATCH (m) WHERE m.name IN split(row.keywords, ',') AND labels(m) <> ['文章'] MERGE p2=(m)-[:关键字]-(n3) RETURN p1, p2
回到顶部