How to add "and" condition in laravel query?

Member

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

How to add "and" condition in laravel query?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by samara , 8 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', 'john@example.com')
            ->get();


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

Related Threads:

How to add query on relational data in laravel?
How does query with multiple where condition work in postgresql?
How to use multiple condition in mongodb query?
How to add wait condition in capybara scenarios?
How to add where condition in left join in mysql?
How to add a "clicked" condition in knockout.js css-binding?