Neo4j CQL - MATCH Command



Neo4j CQL MATCH command is used -

  • To get data about nodes and properties from database
  • To get data about nodes, relationships and properties from database

MATCH command syntax:

MATCH 
(
   <node-name>:<label-name>
)

Syntax Description

Syntax ElementDescription
<node-name>It is a node name we are going to create.
<label-name>It is a node label name

Things to remember -

  • Neo4j Database Server uses this <node-name> to store this node details in Database.As a Neo4j DBA or Developer, we cannot use it to access node details.

  • Neo4j Database Server creates a <label-name> as an alias to internal node name.As a Neo4j DBA or Developer, we should use this label name to access node details.

NOTE - We cannot use MATCH Command alone to retrieve data from database. If we use it alone, then we will InvalidSyntax error.

Example

This Example demonstrates On "What will happen if we use MATCH command alone to retrieve data from Database". Follow the steps given below -

Step 1 - Open Neo4j Data Browser.

Step 1 - Type the below command at dollar prompt in Data Browser.

MATCH (dept:Dept)

Here -

  • dept is a node name
  • Dept is a label name for emp node
Neo4j CQL Tutorial

Step 3 - Click on Execute button and see the success message in the Data Browser.

Neo4j CQL Tutorial

If you observe the error message, it tells us that we can use MATCH command with RETURN clause or an update clause.

In next section, we will discuss about how to use RETURN clause to retrieve data from Database.

Advertisements