I have table like this
product :
id_product | product_name | price
560 | AAA | 1500
561 | BBB | 1750
attr :
id_attr | id_product | size | qty
100 | 560 | S | 11
100 | 560 | M | 9
100 | 560 | L | 7
100 | 560 | XL | 21
How to display
product_name | qty_S | qty_M | qty_L | qty_XL | qty_total | price
AAA | 11 | 9 | 7 | 21 | 48 | 1500
BBB | 0 | 0 | 0 | 0 | 0 | 1750
i try to make query like this :
select p.*, a.*,
sum(a.qty) as qty_total,
[how_to_display_query] as qty_S,
[how_to_display_query] as qty_M,
[how_to_display_query] as qty_L,
[how_to_display_query] as qty_XL,
FROM product p LEFT JOIN attr a
ON p.id_product = a.id_product
group by p.id_product;
===============================================
Please help me, sorry for bad english... Thanks