Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

esperanza's avatar

update query with two conditions

I want a query with two conditions to update but it should be an and conditions. my code is below. it does not work.

DB::table('attendence') ->where([['name',$name] ,['type',null] ]) ->update([ 'checkedout' => $this->data->checkedout, 'type'=> $this->data->type, ]);

0 likes
2 replies
Cinek's avatar
Cinek
Best Answer
Level 6
DB::table('attendence') 
->where('name',$name)
->whereNull('type')
->update([ 'checkedout' => $this->data->checkedout, 'type'=> $this->data->type, ]);
1 like
esperanza's avatar

it worked.

DB::table('attendence') ->where('name',$name) ->whereNull('checkedout') ->update([ 'checkedout' => $this->data->checkedout, 'type'=> $this->data->type, ]);

Please or to participate in this conversation.