Issue
Users::where('application_ID', '=', $request->application_ID)
->where(function ($query) {
$query->where('app_status','!=','')
->orWhere('app_status','!=','Accept')
->orWhere('app_status','!=','Reject')
->orWhere('app_status','!=','Comm Accept')
->orWhere('app_status','!=','Comm Reject');
})->get();
Output:
select * from `user` where `application_ID` = '0320120332330' and (`app_status` != 'Accept' or `app_status` != 'Reject' or `app_status` != 'Comm Accept' or `app_status` != 'Comm Reject')
In the above query if in my table I have app_status = Accept, Reject, Comm Accept and Comm Reject
then the query return all record related to application_ID = '0320120332330'
but I have already mention that if app_status != Accept, Reject, Comm Accept and Comm Reject
then again it return all record. I don't know why?
Solution
use where not in
Users::where('application_ID', '=', $request->application_ID)
->whereNotIn('app_status', ['', 'Accept', 'Reject', 'Comm Accept', 'Comm Reject'])->get();
Answered By - Yazan Fouad Aldbaisy
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.