In this lesson we are going to study about Corss joins in a database.
Cross Join or Cartesian Product:
with three data and Table:B is having one column Y with two data.So the value of m=3 and n=2.
So when we are doing cross join of Table:A with Table:B this will return a table which have
m*n =3*2
=6(Record)
i.e each row of one table is mapped with each row of second table.
Example2: In the below diagram we are having two table's Table:R,Table:S .Table:A is having Two column A,column B
with three data and Table:S is having two column B.column C with two data.So the value of m=3 and n=2.
So when we are doing cross join of Table:A with Table:B this will return a table which have
m*n =3*2
=6(Record)
NOTE: Result table is having all columns of Table:R,Table:S
Syntax:
Explicit cross join:
SELECT *
FROM Table1
CROSS JOIN Table2
Implicit cross join:
SELECT *
FROM Table1 , Table2;
just have a look on below video and try to Cross Join table by your self and you can download the sql scrpit used in this video from here DOWNLOAD LINK
Related Article
Cross Join or Cartesian Product:
- Each row from the first table is combined with the each rows from the second table.
- Rows in the result table is the product of rows in each table.
- For large no of rows ,it takes longer time.
- It does not include any join condition .
- A Cross Join B Result table as A*B.
with three data and Table:B is having one column Y with two data.So the value of m=3 and n=2.
So when we are doing cross join of Table:A with Table:B this will return a table which have
m*n =3*2
=6(Record)
i.e each row of one table is mapped with each row of second table.
Example2: In the below diagram we are having two table's Table:R,Table:S .Table:A is having Two column A,column B
with three data and Table:S is having two column B.column C with two data.So the value of m=3 and n=2.
So when we are doing cross join of Table:A with Table:B this will return a table which have
m*n =3*2
=6(Record)
NOTE: Result table is having all columns of Table:R,Table:S
Syntax:
Explicit cross join:
SELECT *
FROM Table1
CROSS JOIN Table2
Implicit cross join:
SELECT *
FROM Table1 , Table2;
just have a look on below video and try to Cross Join table by your self and you can download the sql scrpit used in this video from here DOWNLOAD LINK
Related Article
- Join
- Equi Join
- Non Equi Join
- Self Join
- Natural Join
- Join with Using clause.
- Join with ON clause
- Outer Join.
No comments:
Post a Comment