Skip to content
Advertisement

MySQL CONCAT and INNER JOIN – Adding another child table

The query below creates a hierarchical relationship with tables and records:

Base on the following tables structures:

I now want to add another table as a sibling of table learning_event so that the relationship becomes:

That is, tables learning_event and assessment have the parent accreditation_standard

Note that both table learning_event and table assessment have relationships to table accreditation_standard using the columns accreditation_standard_fk (which is not a true foreign_key…)

The original query, which works fine, See db-fiddle, but does not contain table assessment as a sibling of table learning_event is:

How should I add the table assessment as required above? Can this be added in the last CONCAT with an extra INNER JOIN? Or does it need another CONCAT as well?

An example of the working code would be great. See db-fiddle

NOTE: I need to retain the format of the original query, just need to add the extra table as sibling as explained.

Advertisement

Answer

Would another UNION ALL in the end provide what you want?

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement