Totally Random Musings from the Edge

Database Soapbox

22 January 2006

This article will take Less than 1 minute to read

When doing full joins across multiple tables you need to limit your results with a WHERE clause to reduce the result set to a more manageable size.

For an example: A full join/cross join between three tables that contain 10, 20, and 30 rows, respectively, WOULD return 10x20x30 = 6,000 rows.

So this is bad mkay…

SELECT t1., t2., t3.* FROM t1, t2, t3;

This isn’t….

SELECT t1., t2., t3.* FROM t1, t2, t3 WHERE t1.i1 = t2.i2 and t3=i3;

So remember to use a WHERE clause kiddoes.