1
我有一個問題MySQL在一個表
假設複雜的問題有兩個表
customer
Cid name
CustomerImage
ImgId Cid
這裏Cid
是外鍵
我知道如果我想看到的一切所有客戶的圖像,我會寫
select customer.Cid, Customer.name , CustomerImage.ImgId from customer INNERJOIN CustomerImage where customer.Cid= CustomerImage.Cid
這說明列表與客戶編號和姓名
我應該在這一點,如果我想說明一個CID的所有圖像在一個專欄中,我添加的每個圖像
Cid image name
所以圖像列應包含所有ImgId爲客戶
那麼查找group_concat:https://dev.mysql.com/doc/refman/5.0/zh-CN/group-by-functions.html#function_group-concat –
或者,您可以使用準備好的語句「爲客戶選擇圖像ID = id「並獲取結果。它可能比將ID分組爲字符串並將其從應用程序中拆分更快。 – Ivan