cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 1.9 - SQL Join Query - How to merge more than one value for sku in same line?

SOLVED

Magento 1.9 - SQL Join Query - How to merge more than one value for sku in same line?

Following are my query,

SELECT cpe.sku AS Sku, ccp.category_id AS Category_Ids 
        FROM catalog_product_entity cpe
        JOIN catalog_category_product ccp ON cpe.entity_id = ccp.product_id

return value like,

Sku    Category_Ids

   1           34
   1           36  
   1           37
   2           65
   2           87

How to merge like,

Sku   Category_Ids

1         34,36,37   
2         65,87
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 1.9 - SQL Join Query - How to merge more than one value for sku in same line?

@AveevaHere you go:

 

SELECT 
     cpe.sku AS Sku, 
     group_concat(ccp.category_id) AS Category_Ids 
FROM catalog_product_entity cpe
JOIN catalog_category_product ccp ON cpe.entity_id = ccp.product_id
GROUP BY cpe.sku
- Tarandeep
Problem solved?Please give 'Kudos' and accept 'Answer as Solution'.

View solution in original post

1 REPLY 1

Re: Magento 1.9 - SQL Join Query - How to merge more than one value for sku in same line?

@AveevaHere you go:

 

SELECT 
     cpe.sku AS Sku, 
     group_concat(ccp.category_id) AS Category_Ids 
FROM catalog_product_entity cpe
JOIN catalog_category_product ccp ON cpe.entity_id = ccp.product_id
GROUP BY cpe.sku
- Tarandeep
Problem solved?Please give 'Kudos' and accept 'Answer as Solution'.