Vorab einen schönen guten Tag. Noch schöner könnte er für mich werden wenn ich mal dieses "kleine Problemchen" lösen würde. Irgendwie finde ich keine "schicke" Lösung.
Folgendes ist vorhanden (vereinfachte Darstellung) :
+-----+
|t1 |
+-----+
|id |
|text1| +-----+
|id_t2|--|t2 |
+-----+ +-----+
|id |
|text2|
|id_t3|-------------+
|id_t3|----+ |
+-----+ | |
+-----+ +-----+
|t3 | |t3 |
+-----+ +-----+
|id | |id |
|text3| |text3|
+-----+ +-----+
SELECT t1.text
t2.text2
t3.text3
FROM t1
INNER JOIN t2 ON (t1.id_t2 = t2.id)
INNER JOIN t3 ON (t2.id_t3 = t3.id)
WHERE t1.id = $suchindex
Mit obiger Anweisung erhalte ich im array = text, text2, text3.
Soweit, so gut, doch ich würde gern array = text, text2, text3, text3 erhalten.
In t2 sind natürlich die Inhalte von id_t3 unterschiedlich, sonst macht das ja keinen Sinn. ;-)
Vielleicht reicht ein Denkanstoss, ich befürchte allerdings ich muss eine zweite Anfrage stellen oder die Tabelle t3 klonen in t4.
Die Tabelle t3 ist für Namensgebung gedacht und nicht sonderlich lang, dennoch wäre es mit einer weiteren Anfrage oder geklonter Tabelle nicht wirklich "schick".