我如何爆炸group_concat并单独显示

时间:2014-11-29 22:17:49

标签: php mysql

您好我已经使用group_concat来合并同一列的以下表记录, 但我怎样才能explode并单独显示为数组。

谢谢

//表A

  Customer ID     Customer_Bill_Name.......                  
    XXX001           XXX Company Name......           
    XXX002           YYY Company Name......         

//表B

 Customer ID          Item ID 1           
     XXX001            WH15 02
     XXX001            600278        
     XX0002            600000  

将所有值连接到一列。

select a.*, group_concat(b.ItemId) joined
from tableA a inner join tableB b on a.customerId = b.customerId
group by a.customerId, a.customer, a.company

结果:

CUSTOMERID  CUSTOMER    COMPANY         JOINED
XXX001      XXX         Company Name    600278,WH15 02
XXX002      YYY         Company Name    600000

//最后表C:我想最终像这样

  Customer ID     Customer_Bill_Name       Item ID 1            Item ID 2           
    XXX001         XXX Company Name         WH15 02             600278 
    XX0002         YYY Company Name         600000  

0 个答案:

没有答案