I've noticed that match(a:Vegetable{name:'Cellery'}) return a
and match(a:Vegetable) where a.name='Cellery' return a
gives me the same result.
Are there any practical differences between the two? The first form seems to work well when you know the property value, but is there a way to use wildcards or a LIKE condition with it?
The EXPLAIN
and PROFILE
options show the execution plan of the query.
They show the exact same execution plan for both queries (on an empty database).
So performance-wise, the two notations should be completely the same.
The first form seems to work well when you know the property value, but is there a way to use wildcards or a LIKE condition with it?
That's correct, WHERE
gives you a lot more flexibility. Basically, the MATCH
clause only allows you to check for equalities that could be written as WHERE a.prop1 = value1 AND a.prop2 = value2 AND ...
. Meanwhile, WHERE
allows you a lot more: the AND
/ OR
/ XOR
and NOT
logical operators, checking for inequalities; using STARTS WITH
, CONTAINS
, ENDS WITH
and regular expressions; checking for node types like WHERE (a:SomeLabel)
or even checking if the variables of the match are part of a pattern like WHERE NOT (a)-[:SOME_REL]->(:SomeLabel)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.