Level 104
Just DB::raw() your working query.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
HI every one please can some help me write this SQL query into laravel eloquent
SELECT SUM(price) FROM (
SELECT COUNT(STOCK_ID)*Price
FROM STOCK ST INNER JOIN PRODUCT PDT ON PDT.PROD_ID=ST.PROD_ID
WHERE PROD_NAME='PENCIL' GROUP BY STOCK_ID LIMIT 6 ) TB
This is what i try out but am messing the whole ting
DB::(table_stock)
->where(['tbl_stock.product_id', $product_id])
->join('tbl.product','stock.product_id', '=' 'tbl_product.product_id')
->count(stock_id)*price
Please or to participate in this conversation.