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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 67
    Comment on it

    In full join all the records of both the table will come in resultant table , it doesn't depend on matching the fields . It is the combination of both left and right join . If matches not found then it will return null .Sometime it is also called Full Outer Join .
    Syntax :

    select * from table1 full outer join table2 on table1.column_name = table2.column_name ;
    

    Example :
    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 Full join see below :

    select Employee_Id , Employee_name , Student_name from Employee_Info full outer join student on Employee_Info.Employee_Id = student.Student_Id ;
     
    Output :All rows from left table and right table will come,don't care fields are matching or not .
    Employee _Id       Employee_name                 Student_name 
            1            Mukesh                          Mukesh
            2            Ayush                           Null
            3            Ishan                           Ayush
            3            Null                            Ayush 
            4            Pranav                          Ishan
            4            Null                            Ishan    
            5            Abhishek                        Null
            6            Ravi                            Null
            7            David                           Null
            16           Null                            Pranav
            15           Null                            Abhishek 
            12           Null                            Ravi
    

 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: