Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • SQL Outer-Left Join

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 246
    Comment on it

    In this Join all the content of both table will come in resultant table either they will be matched or not .
    Outer Join are of two types :
    1) Left Outer Join -> It is also known as left join . In left join all the content of left table will come in resultant and from the right table only matching rows will come . If no rows is matched from right table then null value will be returned .
    Syntax :

    select table1.column1 , table2.column2 ..from table1 left join table2 on table1.column_name = table2.column_name ;
    

    Example of left join :
    First Table name : Employee_Info

    Employee_Id    Employee_name            Employee_Age          Employee _Salary
      1            Mukesh                  23                           100000
      2            Ayush                   24                           200000
      3            Ishan                   20                           400000
      4            Pranav                  35                           700000
      5            Abhishek                26                           800000
      6            Ravi                    25                           300000
      7            David                   40                           800000
    

    Second Table name : student

     
        Student_Id  Student_name            Student_Age          Student_Id
           1        Mukesh                  23                    1
           3        Ayush                   24                    2
           4        Ishan                   20                    4
           16        Pranav                  35                    7
           15        Abhishek                26                    8
           12        Ravi                    25                    3
    

    Now to join these above two tables using left join see below :

    select Employee_Id , Employee_name , Student_name from Employee_Info left join student on Employee_Info.Employee_Id = student.Student_Id ; 
    

    Output :All rows from left table and from right only matching column will come

    Employee _Id       Employee_name                 Student_name 
            1            Mukesh                          Mukesh
            2            Ayush                           Null
            3            Ishan                           Ayush
            4            Pranav                          Ishan
            5            Abhishek                        Null
            6            Ravi                            Null   
    

    continue for right join in next blog .............

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: