我試圖在查詢中使用UNION創建發票產品子圖,然後只想將使用WITH的發票節點傳遞給子查詢。它看起來像下面Neo4J Cypher - Union&With子句用法
MATCH (year:Year)-[]->(month:Month)-[]->(day:Day)-[]->(inv:Invoice)-[]->(prd:Product)
WHERE year.value='2014' and day.value IN ['27','28','29','30','31'] and month.value='January'
RETURN (inv:Invoice)-[:PRODUCT]->(prd:Product)
UNION
MATCH (year:Year)-[]->(month:Month)-[]->(day:Day)-[]->(inv:Invoice)-[]->(prd:Product)
WHERE year.value='2014' and day.value IN ['01','02','03','04'] and month.value='February'
WITH inv
MATCH (inv)-[p:PROCESSED_AT]-(time:Time) WHERE p.time > 700 and p.time < 900
RETURN inv.invid
但我收到此錯誤 - UNION中的所有子查詢必須具有相同的列名稱。任何輸入在哪裏我會錯在這裏?
也許還需要用'AS columnName'替換RETURN中的列 –
我試過上面的查詢,但它沒有工作,它仍然給出相同的錯誤... – deepesh
@DeepeshKuruppath:我編輯的查詢,你可以試試看,如果它的工作 – Kiran