Head's Up! Site migration is underway. Phase 2: migrate recent content
β08-17-2022 03:57 PM
I have many person nodes with a name property. I have one relationship "likes".
What is the query for "Who are the persons that like Ed but do not like (have no relationship with) Alice, Bob, Charlie, and Dan?"
Solved! Go to Solution.
β08-17-2022 08:33 PM
try this:
match(p:Person)-[:LIKES]->(:Person{name: βEdβ})
where not exist ((p)-[:LIKES]->(:Person{name: βAliceβ}))
and not exist ((p)-[:LIKES]->(:Person{name: βBobβ}))
and not exist ((p)-[:LIKES]->(:Person{name: βCharliβ}))
and not exist ((p)-[:LIKES]->(:Person{name: βDanβ}))
return p.name as person
Same query with a little fancier notation:
with [βAliceβ, βBobβ, βDanβ, βCharlieβ] as names
match(p:Person)-[:LIKES]->(:Person{name: βEdβ})
where none( x in names where exists ((p)-[:LIKES]->(:Person{name: x})))
return p.name as person
β08-17-2022 08:33 PM
try this:
match(p:Person)-[:LIKES]->(:Person{name: βEdβ})
where not exist ((p)-[:LIKES]->(:Person{name: βAliceβ}))
and not exist ((p)-[:LIKES]->(:Person{name: βBobβ}))
and not exist ((p)-[:LIKES]->(:Person{name: βCharliβ}))
and not exist ((p)-[:LIKES]->(:Person{name: βDanβ}))
return p.name as person
Same query with a little fancier notation:
with [βAliceβ, βBobβ, βDanβ, βCharlieβ] as names
match(p:Person)-[:LIKES]->(:Person{name: βEdβ})
where none( x in names where exists ((p)-[:LIKES]->(:Person{name: x})))
return p.name as person
All the sessions of the conference are now available online