On this page

Chain Query

Chain query is mostly used when one node is connected to other, which particularly is connected to some other node such as:

Chain: N1-[r1]->N2-[r2]->N3-[r3]->N4;

Nodes: N1,N2,N3,N4
Relations: r1, r2, r3

In such situation, we can use chain query to obtain sub_props , obj_props from any intermediate node.

To get information of a Person who was passenger and caught accident which later was treated by a Doctor

S1=>(@d Person:*)-[IS_DOCTOR]->(@p Person:*)-[@r PASSENGER]->(@c Car:*)-[@f IS_INVOLVED]->(@a Accident:*);RETURN d.name AS Doctor, p.name AS "Person Name", c.name AS "Car Model", a.location AS Location, r.info AS label, a.name AS AccidentID
+----------+----------+---------------+-------------+-----------------+---------+
|Location  |AccidentID|      Car Model|Doctor       |Person Name      |label    |
+----------+----------+---------------+-------------+-----------------+---------+
|Florida   |234       |Hyundai_Elantra|SousannaPinar|EuantheRossana   |Passenger|
+----------+----------+---------------+-------------+-----------------+---------+
|Florida   |234       |        Kia_Rio|SousannaPinar|UdoHalstein      |Passenger|
+----------+----------+---------------+-------------+-----------------+---------+
|Florida   |345       |   Renault_Clio|SousannaPinar|MonroeMaksymilian|Passenger|
+----------+----------+---------------+-------------+-----------------+---------+
|New Jersey|123       |     Ford_Focus|SousannaPinar|EuantheRossana   |Passenger|
+----------+----------+---------------+-------------+-----------------+---------+
|Florida   |345       |     Ford_Focus|SousannaPinar|EuantheRossana   |Passenger|
+----------+----------+---------------+-------------+-----------------+---------+

To get information of a Person who was a Driver and caught accident

S1=>(@p Person:*)-[@r DRIVER]->(@c Car:*)-[@f IS_INVOLVED]->(@a Accident:*);RETURN p.name AS PersonName, c.name AS CarModel, a.location AS Location, r.info AS label, a.name AS AccidentID
+----------+----------+---------------+-----------------+------+
|Location  |AccidentID|       CarModel|PersonName       |label |
+----------+----------+---------------+-----------------+------+
|Florida   |234       |Hyundai_Elantra|SkylerGavril     |Driver|
+----------+----------+---------------+-----------------+------+
|Florida   |234       |        Kia_Rio|MonroeMaksymilian|Driver|
+----------+----------+---------------+-----------------+------+
|Florida   |345       |   Renault_Clio|JasmineRhea      |Driver|
+----------+----------+---------------+-----------------+------+
|New Jersey|123       |     Ford_Focus|UdoHalstein      |Driver|
+----------+----------+---------------+-----------------+------+
|Florida   |345       |     Ford_Focus|UdoHalstein      |Driver|
+----------+----------+---------------+-----------------+------+
|New Jersey|123       | Toyota_Corolla|RobrechtMiloslav |Driver|
+----------+----------+---------------+-----------------+------+
Was this article helpful to you? Yes No