So I’ve just come across something interesting, and I don’t know if it’s been answered before, as I have no clue what it’s called. Lets say that you have two tables; the first has one row and the second has two rows. If you run the following statment:
SELECT t1.*
FROM table1 t1, table2 t2
it returns two rows, and both have the same value, but the first table only has one row! Why does this occur? I didn’t think having another table in the from clause changed anything if you didn’t change the select clause accordingly.
You are selecting a cartesian product of the two tables.
It will return
COUNT(t1) * COUNT(t2)records: all possible combinations of records fromt1with records fromt2.Using
ANSIsyntax, your query would read as: