Laraveldeep
1 year ago

How To Execute 'LIKE' Raw Query with Binding?

Posted 1 year ago by Laraveldeep

Hi,

This works

DB::select("SELECT * FROM `users` WHERE `name` = :name", ['name' => $request->name]);

But this returns empty result

DB::select("SELECT * FROM `users` WHERE `name` LIKE '%:name%'", ['name' => $request->name]);

What is wrong with second query?

Thanks!

Please sign in or create an account to participate in this conversation.