i have created a new node labeled User
CREATE (n:User)
i want to add a name property to my User node i tried it by
MATCH (n { label: 'User' })
SET n.surname = 'Taylor'
RETURN n
but seems it is not affecting .
how can i add properties to a already created node .
Thank you very much.
To create a relationship between two nodes, we first get the two nodes. Once the nodes are loaded, we simply create a relationship between them. The created relationship is returned by the query.
You can change the nodes associated with a label but you can't change the type of a relationship.
In Neo4j, properties are the key-value pairs which are used by nodes to store data. CREATE statement is used to create node with properties, you just have to specify these properties separated by commas within the curly braces "{ }". Syntax: CREATE (node:label { key1: value, key2: value, . . . . . . . . . })
Neo4j CQL CREATE a Node Label We can say this Label name to a Relationship as "Relationship Type". We can use CQL CREATE command to create a single label to a Node or a Relationship and multiple labels to a Node. That means Neo4j supports only single Relationship Type between two nodes.
Your matching by label is incorrect, the query should be:
MATCH (n:User)
SET n.surname = 'Taylor'
RETURN n
What you wrote is: "match a user whose label property is User". Label isn't a property, this is a notion apart.
As Michael mentioned, if you want to match a node with a specific property, you've got two alternatives:
MATCH (n:User {surname: 'Some Surname'})
or:
MATCH (n:User)
WHERE n.surname = 'Some Surname'
Now the combo:
MATCH (n:User {surname: 'Some Surname'})
SET n.surname = 'Taylor'
RETURN n
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With