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

ThanhPv's avatar

How to use both WhereIn and Where

Hi,

I am trying to chain whereIn and Where like this:

DB::table('pwbs')->whereIn('code', 'in', $codeArray)->where('project_id', '=', $id)->delete();
But it is not working.

Could anyone pls suggest me the right syntax to do it?

0 likes
2 replies
Ricardo's avatar
Ricardo
Best Answer
Level 48

@ThanhPv

DB::table('pwbs')->whereIn('code',  $codeArray)
    ->where('project_id', $id)
    ->delete();

The 'in' does not go there

The = is optional

1 like
Cronix's avatar

whereIn(field, [array of values for field])

2 likes

Please or to participate in this conversation.