In this blog, we will give you Laravel where and orWhere Condition Example. we will give you an exceptionally simple illustration of Laravel where() and orWhere() condition and furthermore we will give you an illustration of where() and orWhere in a single query in Laravel 6/7/8.
You can use the where and orwhere strategy in Laravel 6, Laravel 7, and Laravel 8.
where() and orWhere() takes three parameter, let?s see one by one parameter. First parameter is the column name of the table, second parameter is optional bydefault it is equal to operator and last parameter is the value which we have to compare with the table column. Let?s see Laravel where() and orWhere() conditions with Query Builder.
Syntax of where() query in Laravel 6/7/8
where(Column Name, Value);
Example of where condition in SQL
SELECT * FROM employee WHERE id='12';
Example of where() condition in Laravel 6/7/8
$employees = DB::table('employee')
->where('id', 12)
->where('department', 'web development')
->where('age', '>', 30)
->get();
Now we will see the Syntax and example of orWhere() condition in Laravel 6/7/8 and SQL.
Syntax of orWhere() query in Laravel 6/7/8
orWhere(Column Name, Value);
Example of OR WHERE condition in SQL
SELECT * FROM employee WHERE id='12' OR salary='20000';
Example of orWhere() condition in Laravel 6/7/8
$employees = DB::table('employee')
->where('salary', '>', 20000)
->orWhere('name', 'abc')
->get();
I hope you will like the content and it will help you to learn Laravel where and orWhere Condition Example
If you like this content, do share.