how to add a property to existing node neo4j cypher?

30,786

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
Share:
30,786
Kanishka Panamaldeniya
Author by

Kanishka Panamaldeniya

LinkedIn

Updated on September 26, 2020

Comments

  • Kanishka Panamaldeniya
    Kanishka Panamaldeniya almost 4 years

    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.