SQL JOINS

DB2 SQL JOINS : CROSS JOIN


SQL CROSS JOIN returns every possible combination of rows from the every table being joined(This is also called Cartesian product).

[SAMPLE DATA]

SELECT * FROM SQLTEST1 a CROSS JOIN SQLTEST2 b

Point to note: There is no “ON” keyword means no join condition.

— From SQLTEST1 — — From SQLTEST2 —
FILE_KEY FILE_DOB FILE_KEY FILE_NAME
1 10/10/99 1 SUMIT
2 10/10/00 1 SUMIT
3 11/11/01 1 SUMIT
6 12/12/16 1 SUMIT
1 10/10/99 2 AMIT
2 10/10/00 2 AMIT
3 11/11/01 2 AMIT
6 12/12/16 2 AMIT
1 10/10/99 4 AMAN
2 10/10/00 4 AMAN
3 11/11/01 4 AMAN
6 12/12/16 4 AMAN
1 10/10/99 5 RAM
2 10/10/00 5 RAM
3 11/11/01 5 RAM
6 12/12/16 5 RAM

IBM i developer.

View Comments
There are currently no comments.