3

有没有办法使用 WITH 子句在另一个子查询中使用 UNION 的结果?

我正在寻找类似的东西

(
  MATCH (me:Person)-[:RATES]->(r:Rating)-[:RATED_BY]->(them:Person)
  WHERE me.ident = {id} AND r.date = {date}
  RETURN them
  UNION ALL
  MATCH (me:Person)<-[:RATED_BY]-(r:Rating)<-[:RATES]-(them:Person)
  WHERE me.edent = {id} AND r.date = {date}
  RETURN them
)
WITH them
RETURN them.name, COUNT( them.name) as ratingCount
ORDER BY ratingCount DESC
LIMIT 10

cypher 只支持这样的东西。

是的,我知道在这种情况下我应该使用

MATCH (me:Person)-[:RATES|RATED_BY]-(r:Rating)-[:RATES|RATED_BY]-(them:Person)
WHERE me.ident = {id} AND r.date = {date}
RETURN  them.name, COUNT( them.name) as ratingCount
ORDER BY ratingCount DESC
LIMIT 10

这很好而且花花公子,但我认为我会收到一些更复杂的请求,但这是行不通的。

4

0 回答 0