Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-24-2019 09:36 AM
Hi,
Simple questions
NEO 3.4.14
What is difference between:
1.
MATCH a
OPTIONAL MATCH a->b
OPTIONAL MATCH b->c
OPTIONAL MATCH b->d
RETURN a,b,c,d
MATCH a
OPTIONAL MATCH a->b, b->c, b->d
RETURN a,b,c,d
I see difference in result in case a->d returns null.
The first version returns a,b,c
The second version returns a.
Best,
Cezary
06-24-2019 09:49 AM
The OPTIONAL MATCH considers the entire pattern, or all subpatterns as a whole, in the case of your second query. So in your second query if 2 of the subpatterns are present but the 3rd (b->d
) is not, then the entire pattern was not found, and you'll get nulls for all the new variables.
In contrast, your first approach considers each of the patterns separately, so the optional matching of one is not dependent upon the optional matching of another (excepting that the last two optional matches are dependent on b
from the first optional match).
06-24-2019 10:00 AM
Thanks
I expected this but hoped that there is diff:
OPTIONAL MATCH a->b->c
OPTIONAL MATCH a->b, b->c
All the sessions of the conference are now available online