Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-25-2019 05:55 AM
Hi there, I am back again. I have a Cypher query that I am using and it is as follows:
MATCH (c:Collector),(s:Site)
with c,s
WHERE NOT c.name IS NULL,
WHERE NOT s.name IS NULL,
AND c.year =s.year AND c.month = s.month,
RETURN DISTINCT(c.name), s.name, c.month, c.year, s.year
This query is meant to show me collectors that were collecting from the same site at the same time, i.e. same month and year.I am trying to exclude NULLS and NA from the results, how best can I structure the query as this is giving me error.
Also, is it possible to have a variant of the query to have a look at people collecting at the same location but a year apart, how would I change the query to achieve these results?
11-25-2019 06:13 AM
Hi,
You have stray commas on the end of line 3 and line 4. Also if you want to do multiple conditions in a WHERE
clause the 2nd+ conditions can be prefixed with AND
.
I think you want to check whether the property name
exists on those nodes. If that's the case, the following query should do the trick:
MATCH (c:Collector),(s:Site)
WHERE exists(c.name) AND exists(s.name)
AND c.year =s.year AND c.month = s.month
RETURN DISTINCT(c.name), s.name, c.month, c.year, s.year
11-25-2019 07:28 AM
If I slightly amend this query and add a 1 after the s.year in after the AND as shown below, does this translate to that I am now comparing where this are 1 year apart?
MATCH (c:Collector),(s:Site)
WHERE exists(c.name) AND exists(s.name)
AND c.year =s.year+1 AND c.month = s.month
RETURN DISTINCT(c.name), s.name, c.month, c.year, s.year
All the sessions of the conference are now available online