SELECT * FROM `books` WHERE books.type = 'rare' AND books.band - $value < $result
That’s how I think it should be
$books= DB::table('books') ->where('type ','=', 'rare') ->whereRaw('band - $value < $result') // Syntax error
I don’t understand how to work with dynamic variables here.
Answer
Please try it:
$books= DB::table('books') ->where('type ', 'rare') ->whereRaw('band - ? < ?', [$value, $result]) ->get();