Search code examples
databaselaravelsql-query-store

why my sql query have this error when i put into laravel


 $personalSale = DB::select(DB::raw("SELECT *
        FROM purchases a
        WHERE a.purchase_status IN (3001,3002,3003,4000,4001,4002,4003) AND 
        a.purchase_date LIKE "%12/2020" AND
        (a.user_id = 50 OR a.user_id in (SELECT b.user_id
        FROM user_infos b
        WHERE b.referrer_id = 1911000140))
        ORDER BY a.purchase_amount DESC
        LIMIT 10;
        "));

error: syntax error, unexpected '" AND ' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ')'


Solution

  • LIKE "%12/2020" try to replace from " to '