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)

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')

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.

Recommended Posts

View All

How To Create Word Document File In Laravel

In Laravel, use the phpoffice/phpword package to create a word document file. In this example, I'll show you how to create a word document an...

Laravel Multiple Where Condition Example

Laravel multiple where condition, Laravel multiple where not working, Laravel multiple where same column, Laravel 8 Eloquent multiple where condition...

Laravel where clause with date_format() example

laravel db raw where, laravel where date_format, laravel date_format mysql where, laravel date_format example, laravel where with month

Laravel 9 Scout Full Text Search with Algolia Tutorial

A full-text search feature in a web application is incredibly useful for users to navigate through content-rich web and mobile applications, as demons...

Laravel 9 generate RSS Feed Tutorial With Example

Learn how to generate RSS feeds in Laravel 9 with our easy-to-follow tutorial. Get step-by-step instructions and real-world examples. Start today!