cancel
Showing results for 
Search instead for 
Did you mean: 

Query to get nodes who don't have any relationships ?

Mayur
Node Link

Hi Team,

I am learner and i am trying for query which will get only those nodes who don't have any relationship at all ,
Can anyone please help me in that.

Thanks
Mayur

2 ACCEPTED SOLUTIONS

glilienfield
Ninja
Ninja

Try this:

Match(n)

where not exists ( (n)—() )

return n 

View solution in original post

Thanks @glilienfield   after putting that query in Neo4j it was throwing syntax error after looking closely observed that big hypen is nothing but two hypens (--)
Match
(n:Lineage)
where not exists ( (n)--() ) 
return n

View solution in original post

4 REPLIES 4

glilienfield
Ninja
Ninja

Try this:

Match(n)

where not exists ( (n)—() )

return n 

Thanks @glilienfield   after putting that query in Neo4j it was throwing syntax error after looking closely observed that big hypen is nothing but two hypens (--)
Match
(n:Lineage)
where not exists ( (n)--() ) 
return n

Sorry, I did it on my iPhone, which must have converted it to a long dash. Glad you figured it out. 

Yup thanks for the help @glilienfield 

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.