I have three tables with data for which I want to get a combined overview created using an SQL query. The first table "Epics" conists of a column with key values and another column which contains a list of keys. The second and third tables contain a status for each of these keys.
The tables can be illustrated like follows:
Epics
Key Sub-Tasks
+--------+----------------+
| MCR-1 | MCR-21, MCR-31 |
+--------+----------------+
| MCR-2 | MCR-22, MCR-32 |
+--------+----------------+
| MCR-3 | MCR-23, MCR-33 |
+--------+----------------+
QM Sub-Tasks
Key Status
+--------+-------------+
| MCR-21 | DONE |
+--------+-------------+
| MCR-22 | OPEN |
+--------+-------------+
| MCR-23 | IN PROGRESS |
+--------+-------------+
E3 Sub-Tasks
Key Status
+--------+--------------+
| MCR-31 | NOT RELEVANT |
+--------+--------------+
| MCR-32 | DONE |
+--------+--------------+
| MCR-33 | OPEN |
+--------+--------------+
Now I created the following SQL statement:
SELECT epics.'Key' AS 'MCR-Key'
qm.'Status' AS 'QM Status'
e3.'Status' As 'E3 Status'
FROM T3 epics
LEFT JOIN T1 qm ON (qm.'Key' IN epics.'Sub-Tasks')
LEFT JOIN T2 e3 ON (e3.'Key' IN epics.'Sub-Tasks')
However, by using this statement, only the first row contains the status values of tables two and three, but all subsequent rows only contain the epic's key:
Output
MCR-Key QM Status E3 Status
+---------+--------------+-----------+
| MCR-1 | NOT RELEVANT | DONE |
+---------+--------------+-----------+
| MCR-2 | | |
+---------+--------------+-----------+
| MCR-3 | | |
+---------+--------------+-----------+
Any idea why this is the case and how I can resolve this issue?