SAME predicate¶
The SAME predicate checks if all graph elements in a list are the same.
Syntax¶
- same_predicate
same_predicate ::=
SAME '(' element_variable_reference (',' element_variable_reference)+ ')'
Parameters¶
element_variable_reference¶
The reference to a variable that represents a graph element that is checked for equality.
Examples¶
The following examples are based on the example dataset.
Check if all nodes are the same¶
'''
USE movie
MATCH (v@Director{id:488})->(w@Movie), (n@Actor{id:9640})->(m@Movie), (u@`User`)->(p@Movie)
WHERE SAME(w, m, p)
RETURN w.name AS movie_name, v.name AS director, n.name AS actor
LIMIT 3
'''
The preceding statement selects movies directed by a director, movies acted by an actor, and movies rated by users, and uses the SAME predicate to find movies that have all three types of relationships.
Return:
+------------------------------+------------------+-------------------+
| movie_name | director | actor |
+------------------------------+------------------+-------------------+
| A.I. Artificial Intelligence | Steven Spielberg | Haley Joel Osment |
| A.I. Artificial Intelligence | Steven Spielberg | Haley Joel Osment |
| A.I. Artificial Intelligence | Steven Spielberg | Haley Joel Osment |
+------------------------------+------------------+-------------------+