Reputation: 1571
Below is the cypher query which i am using.
MATCH rel=(r:Report)-[:REPORT_CONTAINS_SCHEDULE]->(s:Schedule)
WHERE r.name=$rep_name AND s.name=$sch_val
RETURN rel
$rep_name, $sch_val
are parameters.
If the parameter $sch_val
is null or empty, it should return all the rows under the node Schedule
else if the parameter $sch_val
contains value, it should return only the selected Schedule
value.
How to achieve it?
Upvotes: 1
Views: 973
Reputation: 4052
You can add one more condition in WHERE
to match only rep_name
when sch_val
is null
.
MATCH rel=(r:Report)-[:REPORT_CONTAINS_SCHEDULE]->(s:Schedule)
WHERE (r.name=$rep_name AND $sch_val IS NULL) OR (r.name=$rep_name AND s.name=$sch_val)
RETURN rel
Upvotes: 2