Show nodes which have at least one relationship with specific labelled nodes

Hi !

I am currently trying to show via Neo4j Browser all nodes with a specific Label (Here named "Label1"), when each of them have at least one connection with 3 specific labelled nodes ("X","Y","Z"). I've tried the following query:

MATCH (a)-->(b)
where a:Label1
and size((a)-->(b)) >= 1
and b:X
and b:Y
and b:Z
RETURN a,b, size((a)-->(b)) AS count

However, it returns me everything instead of only nodes with these labels. Did I made something wrong here ?

I've also Tried to exclude nodes with labels I don't want to see, like:

and not b:LabelX

But they still appear.

Thank you :-)

In Neo4j Browser, you must turn off "connect result nodes" in settings on the left.


Hum, now I have nothing returned... However I know that it should return something. Also, I've removed some labels on the filter, and I still have nothing once I turned off "connect result nodes"

count() is a value so the results are returned in tabular format only. If you were to not return count(), then you should be able to see the visualization of the graph with just what you asked to be returned. That is, you should return either paths or nodes and relationships.


There is the answer coming from Stackoverflow website:

MATCH (a:Label1)
WHERE (a)-->(:X)
AND   (a)-->(:Y)
AND   (a)-->(:Z)

Link here:

Thank you anyway