Neo4j - Retrieve Relationship Node's Details



We can use MATCH + RETURN command to view details of Nodes either which are created separately or created as part of a Relationship.

In this Chapter, we will discuss how to retrieve Node's details which are participating in a Relationship.

Syntax

MATCH 
(<node1-label-name>)-[<relationship-label-name>:<relationship-name>]->(<node2-label-name>)
RETURN <relationship-label-name>

Syntax Description

S.No.Syntax ElementDescription
1.MATCH,RETURNThey are Neo4j CQL keywords.
2.<node1-label-name>It is a label name of "From Node" used to create a Relationship.
3.<node2-label-name>It is a label name of "To Node" used to create a Relationship.
4.<relationship-name>It is a name of a Relationship.
5.<relationship-label-name>It is a label name of a Relationship.

Example

This example demonstrates how to Retrieve the "Form Node" and "To Node" Node's details which are used in creating a Relationship.

Step 1 - Open Neo4j Data Browser

Neo4j CQL Tutorial

Step 2 - Type the below command on Data Browser

MATCH (cust)-[r:DO_SHOPPING_WITH]->(cc) 
RETURN cust,cc
Neo4j CQL Tutorial

Step 3 - Click on Execute button and view the results in Grid format by clicking Grid View button.

Neo4j CQL Tutorial

Here we can observe that two Node details which are participating in a Relationship. Also see the results in UI view

Advertisements