I need some help with dynamical column names in a sql query. First I will try to explain my database structure and then the problem.
Database structure:
admin_group table:
+--------+----------------+
| id | language_code |
+--------+----------------+
| 1 | en_UK |
| 2 | de_DE |
| 3 | es_ES |
+--------+----------------+
constructions_meta table:
+--------+-----------------+----------+
| id | admin_group_FK | value |
+--------+-----------------+----------+
| 1 | 1 | 0.13 |
| 2 | 2 | 0.12 |
| 3 | 3 | 0.10 |
+--------+-----------------+----------+
construction_lang table:
+--------+-----------------+----------------+----------------+
| id | en_UK_name | de_DE_name |es_ES_name |
+--------+-----------------+----------------+----------------+
| 1 | Construction 1 | Konstruktion 1 | Construcción 1 |
| 2 | Construction 2 | Konstruktion 2 | Construcción 2 |
| 3 | Construction 3 | Konstruktion 3 | Construcción 3 |
+--------+-----------------+----------------+----------------+
Those are my tables in the database. What I need here is to get the names of the constructions regarding the language code for each construction. For example I want to list the constructions as following:
- Construction 1
- Konstruktion 2
- Construcción 3