sql - Mysql complex issue on a single table -


i have question

suppose there 2 tables

customer   cid  name   customerimage  imgid  cid  

here cid foreign key

i know if want see images of customer write

select customer.cid, customer.name , customerimage.imgid customer innerjoin customerimage customer.cid= customerimage.cid  

this shows list every image customer id , name

what should add in if want show images of 1 cid in 1 column

cid   image name 

so image column should contain imgid customer

i think want group images in 1 row each customer, can group_by clause , group_concat function in mysql:

select c.cid      , с.name      , group_concat(ci.imgid separator ',') customer c join customerimage ci on c.cid = ci.cid  group  c.cid         , c.name 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -