I have area table like :
-----------------------------
id | name | level
-----------------------------
1 | India | country
2 | Some?thing | country
in this table i have added a row with question mark and i want to select that row as follow Query in eloquent :
Area::select(*)->where("name","LIKE", "%Some?thing%")
->where("level","=","country")->get();
but this not give the result because question mark in string in where condition replaced with bindings
the raw sql generated is :
select * from area where name like %Somecountrything% AND level = ?
but i want it like
select * from area where name like %Some?thing% AND level = country
Try this :
Area::whereRaw("name LIKE '%Some?thing%'")
->where("level","=","country")->get();
You can inject raw mysql queries to laravel with the help of whereRaw()
Use whereRaw()
for this
like
DB::table('users')->whereRaw("email LIKE '%Some?thing%'")->get();
Print_r(DB::getQueryLog());
It output like this:
select * from `abc_users` where email LIKE '%Some?thing%'
Hope this helps!
try...
Area::select('*') ....
Full Code:
Client::select('*')->where("name","LIKE", "%xyz?xyz%")
->where("city","=","331")->get();
Output:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With