Let's say we have Post
node on which test
property exists with the value match
. So,
// when searching for 'match'
MATCH(n:Post)
WHERE n.test = 'match'
RETURN n.test AS Match
Result:
Match
-----------------------------
'match'
'match'
'match'
// when searching for 'nomatch'
MATCH(n:Post)
WHERE n.test = 'nomatch'
RETURN n.test AS Match
Result:
(No changes, no records)
Now, what I want get result is like this:
- When
string
matches in that property value, then return last match:
Match
-----------------------------
'match'
- When
string
doesn't match in that property value, then returnstring
:
Match
-----------------------------
'nomatch'
Instead of (No changes, no records)
How can we achieve this? I have tried several hours to achieve this. Please help me.
What I have fiddled out like this for more hours, but not getting the concept how to do this:
MATCH (n:Post)
WHERE n.test = 'match'
RETURN n.test
CASE n.test
WHEN ...
END
ORDER BY n.created_at DESC
LIMIT 1
I hope you understand my question.