neo4j
Delete a node using id Cypher query
The Cypher query can be used to delete nodes using node id that is auto-assigned by neo4j to every node.
MATCH (n:Person)
WHERE ID(n)=10
DETACH DELETE n
The above Cypher query will match the nodes that have a Person label associated with them. Then it will filter the nodes that have id 10 and then it will delete that node along with its relationship to other nodes.
MATCH (n:Movie {id: 5})
DETACH DELETE n
If you have created your own id property in a node and have assigned some value to it, then you can delete this node using that property value by executing the above query.
The query will delete the node that has the label Movie and has property id which has a value 5.
The query will delete the node that has the label Movie and has property id which has a value 5.
Was this helpful?
Similar Posts
- Delete node relationship only Cypher query neo4j
- Get node using id Cypher query neo4j
- Get all related nodes of a node using Cypher query neo4j
- Get the type of relationship variables of a node Cypher query neo4j
- Delete nodes using Cypher query neo4j
- Get all nodes with same label using label name Cypher query neo4j
- Get nodes using multiple ids Cypher query neo4j