Mysql query like this :
SET @sql_dinamis = (
SELECT
GROUP_CONCAT( DISTINCT CONCAT('SUM( IF(id_barang=',id_barang,',jml_bk,0)) AS br',id_barang))
FROM barang_keluar
);
SET @SQL = CONCAT('SELECT month(tgl_keluar) as m,',@sql_dinamis,'
FROM barang_keluar
WHERE month(tgl_keluar) and year(tgl_keluar)=2019
GROUP BY month(tgl_keluar)'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
I want to convert it to laravel eloquent, but i'm confused. Because there exist many statement. There exist PREPARE, EXECUTE, SET, DEALLOCATE etc. You can see query above
How can I convert it to laravel eloquent?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire