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.


Recommended Posts

View All

Laravel 9 Dropzone Image Upload Example Step By Step


The most well-known, free, and open-source library for drag-and-drop file uploads with image previews is Dropzone. I'll be using Laravel 9 in...

Laravel 9 Create Multi Language Website Example Tutorial


Learn how to create a multi-language website with Laravel 9 through our example tutorial. Develop your skills and broaden your audience reach today!

Laravel One to Many Eloquent Relationship


laravel one to many relationship example, laravel one to many sync, one to many relationship laravel 5.6, one to many relationship laravel model

Laravel 8 Custom 404, 500 Error Page Example


How to create custom error page in Laravel 8 and we will also try to tell you why we required to create the custom error page.

Laravel 8 How To Merge Two PDF Files Example


laravel 8 how To merge two PDF files example,how to merge two PDF files in laravel 8,merge two PDF files,pdf,pdf in laravel 8