Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-17-2022 03:47 PM
I don't know why this seems so difficult to figure out. I'm working with the following Nodes and relationships:
I have this code:
MATCH
(n:Notification)-[cfn:CONTACT_FIRST_NAME]->(fn:Name)<-[hfn:HAS_FIRST_NAME]-(c:Contact),
(n)-[cln:CONTACT_LAST_NAME]->(ln:Name)<-[hln:HAS_LAST_NAME]-(c)
RETURN *
And it gives me the first and last names of those who have received a notification and are also a "Contact", but I want to find the names that received a notification, but are not a name owned by a "Contact"
I tried using the WHERE NOT clause, but it didn't yield the proper results. Please help me!
Solved! Go to Solution.
05-17-2022 06:14 PM
Hi @gq16
How about this?
I created two person data.
CREATE (n:Notification {id: 1})-[:CONTACT_FIRST_NAME]->(:Name {name:"Gehad"})<-[:HAS_FIRST_NAME]-(c:Contact),
(n)-[:CONTACT_LAST_NAME]->(:Name {name:"Qaki"})<-[:HAS_LAST_NAME]-(c);
CREATE (n:Notification {id: 2})-[:CONTACT_FIRST_NAME]->(:Name {name:"Koji"}),
(n)-[:CONTACT_LAST_NAME]->(:Name {name:"Annoura"});
The query is like this.
MATCH
(n:Notification)-[cfn:CONTACT_FIRST_NAME]->(fn:Name),
(n)-[cln:CONTACT_LAST_NAME]->(ln:Name)
WHERE NOT (fn)<-[:HAS_FIRST_NAME]-(:Contact)-[:HAS_LAST_NAME]->(ln)
RETURN *
05-17-2022 06:14 PM
Hi @gq16
How about this?
I created two person data.
CREATE (n:Notification {id: 1})-[:CONTACT_FIRST_NAME]->(:Name {name:"Gehad"})<-[:HAS_FIRST_NAME]-(c:Contact),
(n)-[:CONTACT_LAST_NAME]->(:Name {name:"Qaki"})<-[:HAS_LAST_NAME]-(c);
CREATE (n:Notification {id: 2})-[:CONTACT_FIRST_NAME]->(:Name {name:"Koji"}),
(n)-[:CONTACT_LAST_NAME]->(:Name {name:"Annoura"});
The query is like this.
MATCH
(n:Notification)-[cfn:CONTACT_FIRST_NAME]->(fn:Name),
(n)-[cln:CONTACT_LAST_NAME]->(ln:Name)
WHERE NOT (fn)<-[:HAS_FIRST_NAME]-(:Contact)-[:HAS_LAST_NAME]->(ln)
RETURN *
05-18-2022 07:25 AM
Incredible! Thank you for your help Koji!
All the sessions of the conference are now available online