A simple LEFT JOIN
should fix this.
This will give the result from table A
even if they dont exists in table C
, but will display them if they do. This requiers tho that data relation exists in table B
.
Change that to a LEFT JOIN
also if that shouldnt be the case.
SELECT tableA.*,
GROUP_CONCAT(DISTINCT tableB.tbID ORDER BY tableB.sortOrder) AS tbID,
GROUP_CONCAT(DISTINCT tableC.tcID ORDER BY tableC.sortOrder) AS tcID,
tableD1.fullName AS createdByFullName,
tableD2.fullName AS lastUpdatedByFullName
FROM table_A AS tableA
INNER JOIN table_B AS tableB ON tableA.ID = tableB.ID
LEFT JOIN table_C AS tableC ON tableA.ID = tableC.ID
LEFT JOIN table_D AS tableD1 ON tableD1.ID = tableA.createdBy
LEFT JOIN table_D AS tableD2 ON tableD2.ID = tableA.lastUpdatedBy
WHERE tableA.ID = "' . $this_ID . '"
GROUP BY tableB.ID, tableC.ID
LIMIT 1