We use cookies to improve your site experience and analyze website traffic. Click Accept to agree to our website's cookie use as described in our Cookie Policy . Click Preferences to customize your cookie settings.

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results forΒ

- Neo4j
- Technical Discussions
- Neo4j Graph Platform
- A small question about cypher semantics

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β10-06-2022 04:21 AM - edited β10-06-2022 04:24 AM

How should I understand the semantics of these cypher statements. Why the first and second statements have no results and the third statement outputs a line of results?

neo4j@neo4j> with 3 as c1 match (v:nonexist) return count(v) as c2, c1;

+---------+

| c2 | c1 |

+---------+

+---------+

0 rows available after 65 ms, consumed after another 17 ms

neo4j@neo4j> with 3 as c1 match (v:nonexist) return c1;

+----+

| c1 |

+----+

+----+

0 rows available after 41 ms, consumed after another 0 ms

neo4j@neo4j> with 3 as c1 match (v:nonexist) return count(v) as c2;

+----+

| c2 |

+----+

| 0 |

+----+

neo4j@neo4j> match (v:nonexist) return count(v) as c2;

+----+

| c2 |

+----+

| 0 |

+----+

Solved! Go to Solution.

1 ACCEPTED SOLUTION

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β10-06-2022 04:48 AM

A neo4j query produces rows of data for a single match. The way 'with' works is its variable is added to each row of the 'match' result. For example, 'with 3 as c1 match(n) return *', would result in rows as follows (assuming there is a match):

c1, n

3, first instance of n

3, second instance of n

etc.

Based on above, this is how I view each of your questions.

1. when 'with c1 match(v:nonexist)' produces a null result, you get a empty result since you are returning something from the result set (c1).

2. Same reason as #1

3 & 4. These differ from #1 and #2, since you are not requesting something returned from the row data, only the aggregate count of the rows is returned, which is zero for the null rows result.

2 REPLIES 2

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β10-06-2022 04:48 AM

A neo4j query produces rows of data for a single match. The way 'with' works is its variable is added to each row of the 'match' result. For example, 'with 3 as c1 match(n) return *', would result in rows as follows (assuming there is a match):

c1, n

3, first instance of n

3, second instance of n

etc.

Based on above, this is how I view each of your questions.

1. when 'with c1 match(v:nonexist)' produces a null result, you get a empty result since you are returning something from the result set (c1).

2. Same reason as #1

3 & 4. These differ from #1 and #2, since you are not requesting something returned from the row data, only the aggregate count of the rows is returned, which is zero for the null rows result.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β10-06-2022 05:24 AM

@glilienfield Very clear answer! thanks a lot for the reply.

Nodes 2022

OnΒ November 16 and 17 for 24 hours across all timezones, youβll learn about best practices for beginners and experts alike.

Related Content

- Auto identify relation based on field name in tables in Neo4j Graph Platform
- Create a Relationship with the total number of relations from one node to another in Neo4j Graph Platform
- Prevent a unwanted or misspelled property from being added to a node? in Neo4j Graph Platform
- Protecting personal information in Neo4J Enterprise? in Neo4j Graph Platform