4
votes

I have two datasets in Neo4J. I would like to find all nodes within these two datasets that have the same particular property. This is using Cypher code.

I am currently using:

MATCH n=node(*), m=node(*)
WHERE (n.name) AND (m.name) AND 
  n.name=m.name 
RETURN n, m

In the hope to get a result showing all nodes with the same name.

I am aware of this old 2013 post here: neo4j find all nodes with matching properties

But the Cypher code has been significantly updated since this date.

Any help would be great thanks.

1
Post a runnable, concise code example and explain what it does and what you think it should do. - cphlewis
Please provide sample data and expected output, along with what the current code provides and why that is incorrect for your situation. - Adam Houldsworth

1 Answers

5
votes

There are no tables in Neo4j

create index on :LabelA(propertyA);
create index on :LabelB(propertyB);

MATCH (a:LabelA)
MATCH (b:LabelB)
WHERE b.propertyB = a.propertyA
RETURN a,b;