I'm trying to find all the nodes with more than one incoming relationship. Given this data:
a-[has]->b a-[has]->c d-[has]->b
So, I'm looking for a query that returns 'b', because it has more that one incoming.
This query is close. It returns 'a' and 'b', because they both have 2 relations:
match (n)--() with n,count(*) as rel_cnt where rel_cnt > 1 return n;
However, this query (the addition of '-->') doesn't return any and I don't know why:
match (n)-->() with n,count(*) as rel_cnt where rel_cnt > 1 return n;
Am I going about this all wrong?
When you want to return all nodes, relationships and paths found in a query, you can use the * symbol. This returns the two nodes, the relationship and the path used in the query.
neo4j Share on : The Cypher Query to fetch all nodes of a neo4j graph database. In the neo4j graph database, we use Cypher queries to add and get data. To retrieve all nodes or data points in the neo4j graph database we can use the above Cypher query which will show you all nodes in the graph database.
Neo4j CQL CREATE a Node Label We can say this Label name to a Relationship as "Relationship Type". We can use CQL CREATE command to create a single label to a Node or a Relationship and multiple labels to a Node. That means Neo4j supports only single Relationship Type between two nodes.
Create a node with multiple labels. To add labels when creating a node, use the syntax below. In this case, we add two labels.
Does this work for you?
MATCH ()-[r:has]->(n) WITH n, count(r) as rel_cnt WHERE rel_cnt > 1 RETURN n;
I am assuming, perhaps incorrectly, that 'has' is the appropriate relationship type. If not, then try:
MATCH ()-[r]->(n) WITH n, count(r) as rel_cnt WHERE rel_cnt > 1 RETURN n;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With