什麼是在這種情況下做出選擇的最佳方式,並輸出它,而不使用PHP中的嵌套查詢?我寧願使用單個查詢來製作它。如何避免在PHP中循環sql查詢?
我的表是這樣的:
table1 id | items | ---|-------| 1 | item1 | 2 | item2 | 3 | item3 | .. | .. | table2 id | itemid | comment | ---|--------|----------| 1 | 1 | comment1 | 2 | 1 | comment2 | 3 | 2 | comment3 | 4 | 3 | comment4 | 5 | 3 | comment5 | 6 | 3 | comment6 | .. | .. | .. |
這就是我要找的輸出。
item1 comment1 comment2 item2 comment3 item3 comment4 comment5 comment6
在此先感謝
你的意思是加入? http://www.keithjbrown.co.uk/vworks/mysql/mysql_p5.php – Glycerine 2010-10-26 22:23:44
這是每個SQL初學者遇到的問題,您將從w3schools.com展望或sql教科書中受益。 – 2010-10-26 22:27:01