User Id :    Password :      New Member   Forgot Password  
Topic: Cross Join in sql
Anamika singh
13 Aug 2011 at 06:33 AM
Cross Join in sql?
Re: Cross Join in sql
Gaurav
14 Aug 2011 at 07:01 AM
Let's try with 2 tables below:
Table 1: GameScores
PlayerName DepartmentId      Scores
Jason                1                 3000
Irene                 1                 1500
Jane                  2                 1000
David                2                 2500
Paul                   3                 2000
James                3                 2000
Table 2: Departments
DepartmentId             DepartmentName
1                                           IT
2                                       Marketing
3                                           HR
SQL statement :
SELECT* FROM GameScores CROSS JOIN Departments
Result:
PlayerName DepartmentId Scores DepartmentId DepartmentName
Jason                  1              3000         1                       IT
Irene 1 1500 1 IT
Jane 2 1000 1 IT
David 2 2500 1 IT
Paul 3 2000 1 IT
James 3 2000 1 IT
Jason 1 3000 2 Marketing
Irene 1 1500 2 Marketing
Jane 2 1000 2 Marketing
David 2 2500 2 Marketing
Paul 3 2000 2 Marketing
James 3 3000 2 Marketing
Jason 1 3000 3 HR
Irene 1 1500 3 HR
Jane 2 1000 3 HR
David 2 2500 3 HR
Paul 3 2000 3 HR
James 3 3000 3 HR
Total Replies: 1
 
Featured Text Ad

Featured Ad