How to add "and" condition in laravel query?

Member

by shyann , in category: PHP Frameworks , 2 months ago

How to add "and" condition in laravel query?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by samara , 2 months 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.