Database Reference
In-Depth Information
Specifying the User part of the “schema” and identifying the property on which to search are common to both
listings. However, the Cypher query uses START to locate a specific node with a specific value on a specific property.
The necessary values to be returned are specified at the end of the statement.
Note
in the latest release of Neo4j, you should use MATCH as opposed to START when performing reading operations.
In Listings 4-9 and 4-10, respectively, the SQL SELECT statement is modified slightly to return specific values,
and the Cypher MATCH statement is used to perform a similar operation.
Listing 4-9. SQL Query to SELECT a User
SELECT fullname, email, username
FROM User
WHERE username = "greg"
Listing 4-10. Cypher Query to MATCH on a LABEL of Type User
MATCH (u:User {username: "greg"} )
RETURN u.fullname, u.email, u.username
Both listings again specify the User part of the “schema” and use a specific property upon which to search.
However, the Cypher example now uses a MATCH statement to begin the query, then specifies the property and value,
and, finally, specifies at the end of the statement the values to be returned.
UPDATE and SET
To modify existing records within a table, SQL provides an UPDATE command to alter existing values. In Cypher, the
same principle is applied through the SET command, analogous to the SET command in SQL. Listings 4-11 and 4-12
contrast the two usages.
Listing 4-11. SQL Query to UPDATE a User
UPDATE User
SET fullname="Greg Jordan"
WHERE username="greg"
Listing 4-12. Cypher Query to UPDATE a User
MATCH (u:User {username: "greg"} )
SET u.fullname = 'Greg Jordan'
RETURN u
 
 
Search WWH ::




Custom Search