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

How to inline row editing using Laravel 9


Learn how to implement inline row editing in Laravel 9 with our step-by-step guide. Make editing data faster and more efficient on your website.

Generate Laravel PDF with Image Example


In this post, I will demonstrate how to create a Laravel PDF with an image. We occasionally need to generate a PDF with an image for reporting purpose...

Laravel – Where Condition with Two Columns Example


laravel where with two column example, two column where laravel , table column condition in laravel , laravel where column equals column example

Laravel 9 Database Seeder Tutorial Example


Let's go over all of the procedures that will help us understand how the database seeder works in the Laravel application to generate dummy data.

Laravel 9 Generate Sitemap XML File Tutorial


Learn how to generate a sitemap.xml file in Laravel 9 with this step-by-step tutorial. Improve your website's SEO and enhance user experience.