Laravel where and orWhere Condition Example

In this artical we will see how to use where and orwhere condition in laravel 8. For where() and orWhere() method the first argument is the name of the column. The second argument is an operator, which can be any of the database's supported operators. The third argument is the value to compare against the column's value.


Syntax of where() query in laravel 8

where(Coulumn Name, Operator, Value);


Example of where() condition in laravel 8

$users = DB::table('users')
                ->where('id', '=', 5)
                ->where('department', '=', 'Designer')
                ->where('age', '>', 25)


Now, we will see orWhere() condition in laravel 8 and how to write orWhere() condition in laravel. so first we will see SQL query for better understanding.

SQL OR Example

SELECT * FROM users WHERE id='5' OR salary='10000';


Example of orWhere() condition in laravel 8

$users = DB::table('users')
                    ->where('salary', '>', 10000)
                    ->orWhere('name', 'Mark')


You might also like :


Techsolutionstuff | The Complete Guide

I'm a software engineer and the founder of Hailing from India, I craft articles, tutorials, tricks, and tips to aid developers. Explore Laravel, PHP, MySQL, jQuery, Bootstrap, Node.js, Vue.js, and AngularJS in our tech stack.