This query finds employees where the word "india" appears in the address, name, or email field.
×
Search Employees Across Multiple Columns
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class Query_Controller extends Controller
{
public function index()
{
$data = DB::table('employee')->whereAny(['address','name','email'],'like','%india%')->get();
echo "<pre>";
print_r($data->toArray());
}
}
This query searches for "india" in the address, name, or email columns and returns all matching employee records.
×
Search Multiple Columns with LIKE
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class Query_Controller extends Controller
{
public function index()
{
$data = DB::table('employee')->whereAll(['address','name','email'],'like','%india%')->get();
echo "<pre>";
print_r($data->toArray());
}
}
This query skips the first 5 records and fetches the next 10 records from the employee table.
×
Skip First 5 Records and Get Next 10 Records
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class Query_Controller extends Controller
{
public function index()
{
$data = DB::table('employee')->skip(5)->take(10)->get();
echo "<pre>";
print_r($data->toArray());
}
}
Updates the name and address of the employee whose id is 92558.
×
Update Employee Details
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class Query_Controller extends Controller
{
public function index()
{
DB::table('employee')->where('id',92558)->update(['name'=> 'kishna verma','address'=>'meerut']);
}
}
This query finds an employee by their employee ID and updates the employee's name.
×
Update Employee Name by Employee ID
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class Query_Controller extends Controller
{
public function index()
{
DB::table('employee')->where('id',92558)->update(['name'=> 'kishna verma']);
}
}