In this query I have a:
START root = node(*)
MATCH root-[:HAS_DEPARTMENTS]->()<-[:IS_DEPARTMENT]-department-[relationship1:HAS_CATEGORY_SUGGESTION]->categorySuggestion-[relationship2:IS_CATEGORY_SUGGESTION]->()<-[:HAS_CATEGORY_SUGGESTIONS]-root
DELETE relationship1, relationship2
WITH root, department, categorySuggestion
MATCH root-[:HAS_CATEGORIES]->categories
CREATE department-[:HAS_CATEGORY]->categorySuggestion
CREATE categories<-[:IS_CATEGORY]-categorySuggestion
I have a WITH clause separating two parts.
If I move the DELETE down below WITH I will get an error.
I just wonder, how will I know where I should use WITH.
Are there some golden rules?