0
我有兩個表這樣的:MySQL的合併2行成一個
Item
-------------------------------------
|ID | ImageURLID | BannerImageURLID |
-------------------------------------
| 1 | 1 | 2 |
| 2 | 3 | 4 |
| 3 | 5 | 6 |
-------------------------------------
ImageURL
--------------------------------------
|ID | iOSURL | iOSRetinaURL |
--------------------------------------
| 1 | www.test.at | www.testR.at |
| 2 | www.bann.at | www.bannR.at |
| 3 | www.test.at | www.testR.at |
| 4 | www.bann.at | www.bannR.at |
| 5 | www.test.at | www.testR.at |
| 6 | www.bann.at | www.bannR.at |
--------------------------------------
,我想輸出的外觀類似的東西:
-------------------------------------------------------------------------------------
|ID | ImageURLiOS | ImageURLiOSRetina | BannerImageURLiOS | BannerImageURLiOSRetina |
-------------------------------------------------------------------------------------
| 1 | www.test.at | www.testR.at | www.bann.at | www.bannR.at |
| 2 | www.test.at | www.testR.at | www.bann.at | www.bannR.at |
| 3 | www.test.at | www.testR.at | www.bann.at | www.bannR.at |
-------------------------------------------------------------------------------------
我嘗試了一些分組和內部連接但沒有真正作品。 是否有可能使用SQL來完成該操作,還是我必須執行一些PHP處理?
多加入到同一個表:http://stackoverflow.com/questions/199953/how-do-you-join-on-the-same-table-twice-in-mysql – Tim