Laravel where clause
DB::table(‘table_name’)->where(‘column_name’, ‘contional_operator’, value)->get(); is used for where condition in laravel.
Laravel where clause Example 1
We are going to fetch data with where clause in laravel from the table emp.
DB::table('emp')->where('salary', '=',10000)->get();
Will Generate the following query.
//Select * from emp where salary = ‘10000’;
Laravel where clause Example 2
DB::table('emp')->where('salary', '<',10000)->get();
Will Generate the following query.
//Select * from emp where salary < '10000';
Advertisements