lundi 31 juillet 2017

sql syntax or access voilation

My MySql function keep on giving me syntax error message:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in 
 your SQL syntax; check the manual that corresponds to your MySQL server version 
 for the right syntax to use near 'SELECT SUM(sell_rate) FROM (SELECT 
 COUNT(stock_id)*stock_rate sell_rate 
 FRO' at line 2 (SQL: select 
 SELECT SUM(sell_rate) FROM (SELECT COUNT(stock_id)*stock_rate sell_rate 
 FROM tbl_stock st 
 INNER JOIN tbl_product pdt ON pdt.product_id = st.produck_id 
 WHERE produck_name = 'product_id' lIMIT 6
 GROUP BY stock_id)

  from `tbl_stock`)

I have checked all my brackets and they are all closed i have even executed this on MySQL workbench and it is fine but in Laravel it gives me that error here is my function

private function totalprice( $product_id)
   {
   $selltotal = DB::table('tbl_stock')
   ->select(DB::raw("
    SELECT SUM(sell_rate) FROM (SELECT COUNT(stock_id)*stock_rate sell_rate 
    FROM tbl_stock st 
    INNER JOIN tbl_product pdt ON pdt.product_id = st.produck_id 
        WHERE produck_name = 'product_id' lIMIT 6
    GROUP BY stock_id)

    "))->get();
  return $selltotal;
   }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire