what is Cartesian Product? How to use it in
query ?. give example of any table.
SQL Joins are used to relate
information in different tables. A Join condition is a part of the sql query
that retrieves rows from two or more tables. A SQL Join condition is used in
the SQL WHERE Clause of select, update, delete statements.
The Syntax for joining two tables is:
SELECT col1, col2, col3...
FROM table_name1, table_name2;
If a sql join condition is omitted or
if it is invalid the join operation will result in a Cartesian product. The
Cartesian product returns a number of rows equal to the product of all rows in
all the tables being joined. For example, if the first table has 20 rows and the
second table has 10 rows, the result will be 20 * 10, or 200 rows. This query
takes a long time to execute.
EX: there is two table EMP & PAY , each has 4 record when
we performed Cartesian product then it give 16 record in output.
Ex: there is two table EMP & PAY , each has 4 record when
we join this two table & get two column Title & Ename