whereNotNull OR whereNotNull problem Hey Guys!
I need help with following statement:
$getSNPs = $ghcCore->table('snps')->select('*')
->where($cond,$id)
->where('status',$status)
->where(function ($query) {
$query->whereNotNull('odds_ratio');
})
->orwhere(function ($query) {
$query->whereNotNull('beta');
})
->get();
It returns wrong entries. What I need is following:
where cond = 1 AND
where status = statusX AND
where field1 OR field2 is not empty (meaning one field must havea value)
Thanks a lot! Tomas
$getSNPs = $ghcCore->table('snps')
->select('*')
->where($cond,$id)
->where('status',$status)
->where(function ($query) {
$query->whereNotNull('odds_ratio')
->orwhere('beta','!=',null);
})
->get();
Try this hope it will help
thanks!
anyway, I made it this way:
$getSNPs = $ghcCore->table('snps')->select('*')
->where(function ($query) use ($cond,$id,$status) {
$query->where($cond,$id)
->where('status',$status)
->whereNotNull('odds_ratio');
})
->orwhere(function ($query) use ($cond,$id,$status) {
$query->where($cond,$id)
->where('status',$status)
->whereNotNull('beta');
})
->get();
$getSNPs = $ghcCore->table('snps')->select('*')
->where($cond,$id)
->where('status',$status)
->whereRaw('odds_ratio IS NOT NULL OR beta IS NOT NULL')
->get();
Or you can use whereRaw.
Please sign in or create an account to participate in this conversation.