I have code as below to get shipment data where pdf_url
is not NULL
;
$shipment_data = DB::table('shipment')->where([
'shipment_date' => '2017-12-11', ['pdf_url', '<>', 'NULL']])->get();
This has no problem, I get the data I need, but when I'm trying to use the same code to get the data with pdf_url
is NULL
, it has no result.
$shipment_data = DB::table('shipment')->where([
'shipment_date' => '2017-12-11', ['pdf_url', '=', 'NULL']])->get();
What do I missing? I am very sure the DB record is there. I also tried other formats but still no result;
$shipment_data = DB::table('shipment')->where([
'shipment_date' => '2017-12-11', ['pdf_url', 'NULL']])->get();
And
$shipment_data = DB::table('shipment')->where([
'shipment_date' => '2017-12-11', 'pdf_url' => 'NULL'])->get();
EDIT: I can use whereRaw
, but I'll prefer to use where
instead. Code below has no issue;
$shipment_data = DB::table('shipment')
->whereRaw('shipment_date = "2017-12-11" AND pdf_url is NULL')->get();
whereNull
orwhereRaw
instead – Tribadism