Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-27-2021 02:28 AM
I have the following Spring Data repository method:
@Query(value = "MATCH (p:Person) WHERE p.name = $name and p.age = $age RETURN p", countQuery = "MATCH (p:Person) WHERE p.name = $name and p.age = $age RETURN count(p)")
Page<Person> findAllPersons(String name, Integer age, Pageable pageable);
sometimes I'll pass NULL as a name or age parameters (or both of them) and in such case don't want that null parameters were evaluated in WHERE Cypher statement. Is it possible to manage such case with pure Cypher in order to check name or/and age on NULL and exclude them from WHERE ? Thanks
Solved! Go to Solution.
05-27-2021 06:12 AM
You can try
MATCH (p:Person)
WHERE
( $name is null OR p.name = $name )
AND
( $age is null OR p.age = $age ) RETURN p
05-27-2021 06:12 AM
You can try
MATCH (p:Person)
WHERE
( $name is null OR p.name = $name )
AND
( $age is null OR p.age = $age ) RETURN p
All the sessions of the conference are now available online