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

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 195
    Comment on it

    2) Right Outer Join -> It is also known as Right join . In right join all the content of right table will come in resultant and from the left table only matching rows will come . If no rows is matched from left table then null value will be returned .

    Syntax :

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

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

    select Employee_Id , Employee_name , Student_name from Employee_Info right 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
            3            Ishan                           Ayush
            4            Pranav                          Ishan
            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: