I have done the mysql query but only problem i want to convert in laravel syntax. my output is coming very fine but i need to convert into laravel. Here is my below query:-
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'MAX(IF(size = ''',
size,
''', qty, NULL)) AS ',
size
)
) INTO @sql
FROM order_product_sizes;
SET @sql = CONCAT('SELECT order_products.product_name, ', @sql, ' ,sum(qty) as total
FROM order_products join order_product_sizes
on order_product_sizes.order_product_id = order_products.id
group by order_product_sizes.order_product_id');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
I have tried with DB::SELECT()..... but its not working. Can anyone help me. Thanks in advance .
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire