Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Not clear where I wanna use WITH
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Johnny Weng Luu  
View profile  
 More options May 20 2012, 3:45 am
From: Johnny Weng Luu <johnny.weng....@gmail.com>
Date: Sun, 20 May 2012 00:45:09 -0700 (PDT)
Local: Sun, May 20 2012 3:45 am
Subject: Not clear where I wanna use WITH

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?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Hunger  
View profile  
 More options May 20 2012, 5:18 am
From: Michael Hunger <michael.hun...@neotechnology.com>
Date: Sun, 20 May 2012 11:18:21 +0200
Local: Sun, May 20 2012 5:18 am
Subject: Re: [Neo4j] Not clear where I wanna use WITH
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Johnny Luu  
View profile  
 More options May 20 2012, 5:54 pm
From: Johnny Luu <johnny.weng....@gmail.com>
Date: Sun, 20 May 2012 23:54:44 +0200
Local: Sun, May 20 2012 5:54 pm
Subject: Re: [Neo4j] Not clear where I wanna use WITH
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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Hunger  
View profile  
 More options May 20 2012, 6:07 pm
From: Michael Hunger <michael.hun...@neotechnology.com>
Date: Mon, 21 May 2012 00:07:34 +0200
Local: Sun, May 20 2012 6:07 pm
Subject: Re: [Neo4j] Not clear where I wanna use WITH
Johnny,

do you mind reposting your question on SO, so that we can put the answer there too?

will make it easier for people to find.

Michael

And we'll improve the docs too!

Am 20.05.2012 um 23:54 schrieb Johnny Luu:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Johnny Weng Luu  
View profile  
 More options May 20 2012, 9:59 pm
From: Johnny Weng Luu <johnny.weng....@gmail.com>
Date: Sun, 20 May 2012 18:59:21 -0700 (PDT)
Local: Sun, May 20 2012 9:59 pm
Subject: Re: [Neo4j] Not clear where I wanna use WITH

Np.

Here is the question in Stackoverflow:

http://stackoverflow.com/questions/10678761/where-to-use-with

Johnny


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »