neo4j
  1. neo4j-return-clause

Return Clause - (Neo4j General Clauses)

The RETURN clause is a general clause in Neo4j's query language, Cypher. It's used to specify what data to return from a query, after performing filtering and aggregation operations. This clause can be used with a variety of other clauses to customize the output of a query and make it more useful.

Syntax

The basic syntax of the RETURN clause is as follows:

RETURN [expression1, expression2, ... expressionN]

Here expression represents any valid Cypher expression that can be evaluated to a value, which can include variables, properties, and functions. Multiple expressions can be separated by commas to return multiple values.

Example

Here is an example of using the RETURN clause to return data from a Neo4j database:

MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
WHERE p.name = 'Tom Hanks'
RETURN p.name, m.title

In this example, we are filtering data by only finding people who have acted in a movie and whose name is 'Tom Hanks'. We use the RETURN clause to specify that we want to return the name of the person and the title of the movie they acted in.

Output

The output of a query that includes a RETURN clause will be a set of rows, where each row represents the values returned for each expression specified in the RETURN clause.

Explanation

The RETURN clause is a general clause in Cypher that is used to specify what data to return from a query. It can be used with other clauses such as MATCH, WHERE, and CREATE to perform filtering and aggregation operations on the data before returning it. The expressions specified in the RETURN clause can include variables, properties, and functions, and multiple expressions can be separated by commas to return multiple values.

Use

The RETURN clause is used to specify the data to be returned from a query in a Neo4j database. It can be used with other clauses to perform filtering and aggregation operations on the data before returning it.

Important Points

  • The RETURN clause is a general clause in Cypher used to specify what data to return from a query.
  • Expressions specified in the RETURN clause can include variables, properties, and functions.
  • Multiple expressions can be separated by commas to return multiple values.

Summary

In summary, the RETURN clause is a general clause in Cypher used to specify what data to return from a query in a Neo4j database. It can be used with other clauses to perform filtering and aggregation operations on the data before returning it. Multiple expressions can be separated by commas to return multiple values.

Published on: