How to add "and" condition in laravel query?

Member

by shyann , in category: PHP Frameworks , 10 days ago

How to add "and" condition in laravel query?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by samara , 9 days ago

@shyann 

To add multiple conditions using the "AND" operator in a Laravel query, you can use the where() method multiple times in a chain like below:

1
2
3
4
$users = DB::table('users')
            ->where('name', 'John')
            ->where('email', '[email protected]')
            ->get();


This will generate a query with the "AND" condition for both name and email columns.