do you mind reposting your question on SO, so that we can put the answer there too?
> This is very good information!
> Could be very useful in the doc!
> Johnny
> Sent from my iPad
> On 20 maj 2012, at 11:18, Michael Hunger <michael.hun...@neotechnology.com> wrote:
>> you get an error, b/c WITH creates a boundary which declares which variables are available in the next query part.
>> If you leave off the WITH cypher adds an implicit WITH between two query parts that it can identify (e.g. read followed by write) that carries over _ALL_ the context to the next part which is often much more than you need.
>> If you use with you can declare explicitly what you need, making the query easier to understand and the execution more efficient.
>> As you don't declare relationship1, relationship2 in your WITH they are not available in the next query part, so DELETE cannot see them.
>> As WITH is very similar to return, it is also possible to use aggregates there which allows you to create new intermediate results that look differently from the subgraphs you queried first (which allows you to work on the aggregates, e.g. create a HAVING using WITH and WHERE)
>> Michael
>> Am 20.05.2012 um 09:45 schrieb Johnny Weng Luu:
>>> In this query I have a:
>>> START root = node(*)
>>> MATCH root-[:HAS_DEPARTMENTS]->()<-[:IS_DEPARTMENT]-department-[relationship1:HAS _CATEGORY_SUGGESTION]->categorySuggestion-[relationship2:IS_CATEGORY_SUGGES TION]->()<-[:HAS_CATEGORY_SUGGESTIONS]-root
>>> WHERE root.name = "Store" and department.name = "foo" and categorySuggestion.name = "bar"
>>> 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?