Home > Software design >  How to write two where conditions in DB query in Laravel?
How to write two where conditions in DB query in Laravel?

Time:10-19

I have one query which will check one column values by using where condition now I want to check one more column in the query by using where condition please help me

DB::table('contents')->where('name','Python')->get();

Now that I need is to check one more condition where('price',null) is there any way inorder to write two where conditions with one where condition it will check both conditions

CodePudding user response:

You can just chain multiple where conditions, so :

DB::table('contents')->where('name','Python')->where('price',null)->get();

would work fine.

CodePudding user response:

Kindly make an array of conditions. So the query will be,

DB::table('contents')->where([['name','Python'], ['price', null]])->get();

Let me know its solves your issue or not.

  • Related