我對mysql查詢沒有什麼問題。我需要GROUP_CONCAT中的GROUP_CONCAT之類的東西。 LOOK:使用GROUP_CONCAT查詢
數據庫設計:
SELECT cid, country, capital,
GROUP_CONCAT(DISTINCT mid, '=',city SEPARATOR '|*|') AS data
FROM t1
INNER JOIN t2 ON t2.c_id = t1.cid
INNER JOIN t3 ON t2.c_id = t3.mid
WHERE t1.cid =1
返回
[cid] => 1
[country] => France
[capital] => Paris
[data] => 1=Lyon|*|2=Chartres|*|3=Valence
但我想加盟此查詢表T4(我沒有想法如何做到這一點)和如果輸出看起來像這樣會很好
[cid] => 1
[country] => France
[capital] => Paris
[data] => 1=Lyon=|*|2=Chartres=Max#Alex#Frank|*|3=Valence=John
ps。 t4.m_id = t3.mid
+1 look about right :) – Bohemian