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

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 198
    Comment on it

    SQL Cross means cartesian product of the rows of two or more tables . It return all the rows of the table when each row of the first table combined with the each row of the second table . It is also known as cartesian or cross join .
    Cross Join can be represent by two ways :
    1) Using Join Syntax .
    2) from clause without using a where clause .

    Syntax :

    select * from table1 cross join table2  ;
    or
    select * from table1 , table2 ;
    

    Example of Cross join :
    First Table name : Employee_Info

    Employee_Id    Employee_name            Employee_Age         
      1            Mukesh                      23                      
      2            Ayush                       24                   
    

    Second Table name : student

        Student_name            Student_Age        
          Abhishek                26                    
          Ravi                    25                    
    

    Query for Cross Join :

    select * from Employee_Info cross join student ;
    

    Output :

    Employee_Id      Employee_name      Employee_Age      Student_name      Student_Age
         1            Mukesh                 23             Abhishek            26      
         2            Ayush                  24             Abhishek            26    
         1            Mukesh                 23             Ravi                25      
         2            Ayush                  24             Ravi                25    
    

 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: