The following cypher query fails at the last line because p2 is only defined within scope after EXISTS, but is there a way to bring it out of that scope somehow (e.g. set it to a global variable) and return it?
MATCH (p:Person)
WHERE EXISTS {
MATCH (p{name: 'José'})<-[:CHILD_OF]-(p2:Person)
WHERE p2.name IN ['Roberto', 'Gustavo']
}
RETURN (p), (p2) // fails
P.S.: I know that the easiest solution is to just NOT use the scope in the first place, my question is whether the functionality I'm looking for exists.