Using Set clause, you can upload new houses to an current Node or Relationship, and additionally upload or update current Properties values.
In this bankruptcy, we are going to speak about the way to −
- Set a belongings
- Remove a assets
- Set more than one properties
- Set a label on a node
- Set multiple labels on a node
Setting a Property
Using the SET clause, you can create a new property in a node.
Syntax
Following is the syntax for placing a property.
MATCH (node:label{properties . . . . . . . . . . . . . . })
SET node.property = value
RETURN node
Example
Before intending with the instance, first create a node named Dhawan as proven under.
CREATE (Dhawan:player{name: "shikar Dhawan", YOB: 1985, POB: "Delhi"})
Following is a sample Cypher Query to create a belongings named “highestscore” with price “187”.
MATCH (Dhawan:player{name: "shikar Dhawan", YOB: 1985, POB: "Delhi"})
SET Dhawan.highestscore = 187
RETURN Dhawan
To execute the above query, carry out the subsequent steps −
Step 1 − Open the Neo4j laptop App and start the Neo4j Server. Open the integrated browser app of Neo4j using the URL http://localhost:7474/ as shown within the following screnshot.
Step 2 − Copy and paste the preferred query in the dollar prompt and press the play button (to execute the question) highlighted inside the following screenshot.
Result
On executing, you'll get the subsequent result. Here you could examine that a property with a key-price pair highestscore/187 is created in the node named “Dhawan”.
Removing a Property
You can eliminate an existing belongings by passing NULL as cost to it.
Syntax
Following is the syntax of doing away with a property from a node using the SET clause.
MATCH (node:label {properties})
SET node.property = NULL
RETURN node
Example
Before intending with the example, first create a node “jadeja” as proven below.
Create (Jadeja:player {name: "Ravindra Jadeja", YOB: 1988, POB: "NavagamGhed"})
Following is a sample Cypher Query which removes the property named POB from this node using the SET clause as shown beneath.
MATCH (Jadeja:player {name: "Ravindra Jadeja", YOB: 1988, POB: "NavagamGhed"})
SET Jadeja.POB = NULL
RETURN Jadeja
To execute the above question, carry out the following steps −
Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j the usage of the URL http://localhost:7474/ as shown in the following screenshot.
Step 2 − Copy and paste the favored query within the dollar activate and press the play button (to execute the question) highlighted in the following screenshot.
Result
On executing, you'll get the following end result. Here you may take a look at that the variable named POB became deleted.
Setting Multiple Properties
In the identical manner, you can create a couple of houses in a node the usage of the Set clause. To do so, you need to specify those key fee pairs with commas.
Syntax
Following is the syntax to create multiple properties in a node the usage of the SET clause.
MATCH (node:label {properties})
SET node.property1 = value, node.property2 = value
RETURN node
Example
Following is a pattern Cypher Query which creates a couple of homes in a node the use of the SET clause in Neo4j.
MATCH (Jadeja:player {name: "Ravindra Jadeja", YOB: 1988})
SET Jadeja.POB: "NavagamGhed", Jadeja.HS = "90"
RETURN Jadeja
To execute the above question, perform the following steps −
Step 1 − Open the Neo4j laptop App and start the Neo4j Server. Open the integrated browser app of Neo4j using the URL http://localhost:7474/ as proven in the following screenshot.
Step 2 − Copy and paste the desired query inside the dollar activate and press the play button (to execute the query) highlighted inside the following screenshot.
Multiple Properties
Result
On executing, you may get the following end result. Here you could have a look at that homes named POB and HS had been created.
Setting a Label on a Node
You can set a label to an present node the usage of the SET clause.
Syntax
Following is the syntax to set a label to an current node.
MATCH (n {properties . . . . . . . })
SET n :label
RETURN n
Example
Before intending with the example, first create a node “Anderson” as shown underneath.
CREATE (Anderson {name: "James Anderson", YOB: 1982, POB: "Burnely"})
Following is a sample Cypher Query to set a label on a node the usage of the SET clause. This question provides the label “player” to the node Anderson and returns it.
MATCH (Anderson {name: "James Anderson", YOB: 1982, POB: "Burnely"})
SET Anderson: player
RETURN Anderson
To execute the above query, perform the following steps −
Step 1 − Open the Neo4j desktop App and begin the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot.
Step 2 − Copy and paste the favored question within the dollar prompt and press the play button (to execute the question) highlighted inside the following screenshot.
Result
On executing, you may get the subsequent end result. Here you may look at that the label named “player” is added to the node.
Setting Multiple Labels on a Node
You can set more than one labels to an present node the use of the SET clause. Here you need to specify the labels with the aid of separating them with colons “:”.
Syntax
Following is the syntax to set a couple of labels to an present node using the SET clause.
MATCH (n {properties . . . . . . . })
SET n :label1:label2
RETURN n
Example
Before intending with the instance, first create a node named “Ishant” as shown beneath.
CREATE (Ishant {name: "Ishant Sharma", YOB: 1988, POB: "Delhi"})
Following is a sample Cypher Query used to create more than one labels on a node the usage of the SET clause.
MATCH (Ishant {name: "Ishant Sharma", YOB: 1988, POB: "Delhi"})
SET Ishant: player:person
RETURN Ishant
To execute the above query, perform the subsequent steps −
Step 1 − Open the Neo4j laptop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot.
Step 2 − Copy and paste the preferred query within the dollar spark off and press the play button (to execute the question) highlighted in the following screenshot.
Result
On executing, you'll get the subsequent end result. Here you could look at that two labels - man or woman and participant – are introduced to the node named Ishant.