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)
->get();
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')
->get();
You might also like :
Top comments (0)