On this page

Nested query

Nested Query is used when a subject node is having two relations to two other object node and we do require the information from both the objects as well as subject node.

It is really helpful when one node is having multiple relation to other distinct node.

To check for all the people who were both driver and passenger

S2=>[S1=>(@p Person:*)-[@d DRIVER]->(@c Car:*)]-[@g PASSENGER]->(@f Car:*);RETURN p.name AS Pname, d.info AS driver, g.info AS Passenger, COUNT(p.name) AS CNT
+---------+------+-----------------+---+
|Passenger|driver|            Pname|CNT|
+---------+------+-----------------+---+
|Passenger|Driver|      UdoHalstein|2  |
+---------+------+-----------------+---+
|Passenger|Driver| RobrechtMiloslav|2  |
+---------+------+-----------------+---+
|Passenger|Driver|      JasmineRhea|2  |
+---------+------+-----------------+---+
|Passenger|Driver|MonroeMaksymilian|2  |
+---------+------+-----------------+---+
|Passenger|Driver|     SkylerGavril|2  |
+---------+------+-----------------+---+
|Passenger|Driver|   EuantheRossana|2  |
+---------+------+-----------------+---+
Was this article helpful to you? Yes No