Reputation: 97
I have a sql table having multiple rows in which i want to get single row from same column value in my case SKU Column.I want to merge multiple rows from same sku value into one row having all values of attribute_id and attribute_value.
Upvotes: 3
Views: 1109
Reputation: 520908
If you are OK with having a comma-separated list of attribute IDs and values per each sku
, then you could use GROUP_CONCAT
:
SELECT sku,
GROUP_CONCAT(attribute_id) AS attribute_id,
GROUP_CONCAT(attribute_value) AS attribute_value
FROM yourTable
GROUP BY sku
Upvotes: 5