Issue
How do I apply Laravel's Eloquent whereIn() so that it includes null?
I've tried:
User::whereIn("column", [null, 1, 2]) -> get();
And
User::whereIn("column", [DB::raw("null"), 1, 2]) -> get();
But both queries return no results.
Thanks!
Solution
I don't think you can pass null
in in
mysql statement. If you run the query in mysql console it will skip the null.
Try User::whereNull('column')->orWhereIn('column', array(1, 2))->get();
Answered By - Saumini Navaratnam
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.