I am trying to match nodes a
where the sizes for a.category
are less than or equal to 9. I would like to place a condition for a.category
sizes that are exactly the size of 9, that only the nodes with their first character being ‘c’ will be matched. Here is an example of what I want to achieve:
SELECT * FROM cypher('Graph', $$
MATCH (a)
WHERE size(a.category <= 9) AND
substring(a.category, 0, 1)) = 'c' ONLY IF (size(a.category) = 9)
RETURN a.name
$$) AS (name agtype);
If the IF
statement does not exist or will not work in this circumstance, are there any ways to achieve the same result with a different method?
2
Answers
use
AND
instead ofIF
like this
The situation you described can be achieved by the following query
You can split the logic as first matching if the size of category is 9 OR (size is 9 AND category starts with letter c).