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 Use Yajra Datatables in Laravel 9 Application


Learn how to enhance your Laravel 9 application with Yajra Datatables. This tutorial will guide you through the steps of integrating and using it.

Most Important Array Methods in JavaScript


Learn the most important array methods in JavaScript, including push, pop, shift, unshift, forEach, map, filter, reduce, and find. Improve your coding...

Laravel Google Chart Example Tutorial


laravel google chart example, dynamic charts in laravel, laravel google pie chart, laravel google line chart example, google chart in laravel, laravel...

Laravel 8 Stripe Subscription Tutorial Using Cashier Example


laravel cashier, stripe laravel, laravel subscription tutorial, laravel 8 cashier tutorial, laravel 8 stripe subscription tutorial

Laravel Middleware Tutorial With Example


Laravel middleware implements some functionality during the request hit on the specific URI, as its name says.