Reputation: 1477
I'm trying to convert a query to a Laravel query but when I use raw method
I can't make it work.
My query:
SELECT * FROM leagues
WHERE SOUNDEX(name)
LIKE CONCAT('%',SUBSTRING(SOUNDEX('Eng. Premier League'),5),'%');
I couldn't find any docs online that answer me.
Upvotes: 1
Views: 409
Reputation: 15941
You can use WhereRaw()
to conver this query to Laravel Query Builder.
DB::table('leagues')
->whereRaw("SOUNDEX(name)
LIKE CONCAT('%',SUBSTRING(SOUNDEX('Eng. Premier League'),5),'%')");
if you don't prefer WhereRaw()
then you have to use DB::raw()
in your Conditions
DB::table('leagues')
->where( DB::raw('SOUNDEX(name)'), 'LIKE', DB::raw("CONCAT('%',SUBSTRING(SOUNDEX('Eng. Premier League'),5),'%')") );
Hope this helps.
Upvotes: 4