Reset
Get Employee Details from Multiple Tables
Program Info
Program Code
×

Get Employee Details from Multiple Tables

This query joins the employee, users, and contact tables using the employee ID. It fetches the employee's email, address, name, username, and mobile number in one result.

Footer

×

Get Employee Details from Multiple Tables

<?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')
        ->join('users','employee.emp_id','=','users.emp_id')
        ->join('contact','employee.emp_id','=','contact.emp_id')
        ->select('employee.email','employee.address','users.displayName','users.username','contact.mobile')
        ->get();
        echo "<pre>";
        print_r($data->toArray());

    }
}

Footer

Get Employee Details with User and Contact Information
Program Info
Program Code
×

Get Employee Details with User and Contact Information

This query joins the employee, users, and contact tables using the employee ID. It fetches employee details along with the user's name, username, and mobile number.

Footer

×

Get Employee Details with User and Contact Information

<?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')
        ->join('users','employee.emp_id','=','users.emp_id')
        ->join('contact','employee.emp_id','=','contact.emp_id')
        ->select('employee.*','employee.address','users.displayName','users.username','contact.mobile')
        ->get();
        echo "<pre>";
        print_r($data->toArray());

    }
}

Footer

Get Employee Name by Address and Gender
Program Info
Program Code
×

Get Employee Name by Address and Gender

This query gets the name of one employee whose address is India and gender is O. It returns only the employee's name.

Footer

×

Get Employee Name by Address and Gender

<?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')->where(['address'=>'india','gender'=>'O'])->value('name');
        echo "<pre>";
        print_r($data);


    }
}

Footer

Get Employee Names by Email
Program Info
Program Code
×

Get Employee Names by Email

This query gets employee names using their email addresses as keys and displays the result as an array.

Footer

×

Get Employee Names by Email

<?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')->pluck('name','email');
        echo "<pre>";
        print_r($data->toArray());


    }
}

Footer

Get Employee Names by Email As Key
Program Info
Program Code
×

Get Employee Names by Email As Key

This query gets employee names with their email addresses and displays each email with the employee name.

Footer

×

Get Employee Names by Email As Key

<?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')->pluck('name','email');
        foreach($data as $email => $name)
        {
            echo "<pre>";
            echo $email.' '.$name;
        }


    }
}

Footer

Get Employees Created in a Specific Year
Program Info
Program Code
×

Get Employees Created in a Specific Year

This query gets all employees whose created_at date is from the year 2024.

Footer

×

Get Employees Created in a Specific Year

<?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')->whereYear('created_at','2024')->get();
        echo "<pre>";
        print_r($data->toArray());
    }
}

Footer

Get Employees Created in October
Program Info
Program Code
×

Get Employees Created in October

This query gets all employees whose created_at month is October.

Footer

×

Get Employees Created in October

<?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')->whereMonth('created_at','10')->get();
        echo "<pre>";
        print_r($data->toArray());
    }
}

Footer

Get Employees Created on a Specific Date
Program Info
Program Code
×

Get Employees Created on a Specific Date

This query gets all employees from the employee table whose created_at date is 2024-10-09. It ignores the time and checks only the date.

Footer

×

Get Employees Created on a Specific Date

<?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')->whereDate('created_at','2024-10-09')->get();
        echo "<pre>";
        print_r($data->toArray());
    }
}

Footer

Get Employees Created on a Specific Day
Program Info
Program Code
×

Get Employees Created on a Specific Day

This query gets all employees whose created_at date is on the 31st day of any month. It does not check the month or year.

Footer

×

Get Employees Created on a Specific Day

<?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')->whereDay('created_at','31')->get();
        echo "<pre>";
        print_r($data->toArray());
    }
}

Footer

Get Employees Outside an ID Range
Program Info
Program Code
×

Get Employees Outside an ID Range

This query gets all employees whose ID is not between 10 and 90.

Footer

×

Get Employees Outside an ID Range

<?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')->whereNotBetween('id',[10,90])->get();
        echo "<pre>";
        print_r($data->toArray());
    }
}

Footer

Showing page  5  of  8  (Total  77 records)
« Prev  1 ... 3  4  5  6  7  8  Next »
×
Name : Krishna Verma    |    Father's Name : Mr. Satish Kumar    |    Email ID : krishnaverma28081997@gmail.com    |    Religion : Hindu    |    Address : Dayampur, kanker khera, Meerut Cantt (250001), UP    |    Date of Birth : 28 August 1997    |    Marital Status : Non-Married    |    Place of Birth : Dayampur Kanker Khera Meerut Cantt.    |    Gender : Male    |    Age : 28    |    Contact : 9520335394    |    Father's Occupation : Sports man    |    Mother's Name : Smt. Kuntesh Devi    |    Mother's Occupation : Homemaker    |    Number of Brothers : 1    |    Number of Sisters : 1    |    Current Residence : Dayampur kanker khera meerut cantt    |    Family Type : Nuclear Family    |    Family Name : verma    |    Height : 5' 6"    |    Weight : 70 kg    |    Complexion : Fair    |    Body Type : Athletic    |    Hair Color : Black    |    Health Status : Good    |    Any Physical Disability : No    |    Highest Qualification : B.Tech (CSE)    |    Master Skill : PHP Laravel    |    Total Projects : 40 +    |    Total Skills : 25 +    |    Languages Known : Hindi and English    |    Website : krishnaportfolio.in    |    Siblings : 3    |    Nationality : Indian    |    Total Experience : 5 Years    |    LinkedIn : https://www.linkedin.com/in/krishna-verma-840b71356/    |    Total Programs : 10000    |    Total Projects : 40    |    Total Skills : 25    |    Total Experience : 5    |    Total DSA Problems : 200    |    Total Served Companies : 2    |    Leetcode : https://leetcode.com/u/krishnavermadeveloper/    |    Naukri : https://www.naukri.com/mnjuser/profile?id=&altresid