[nycphp-talk] SQL question
Steve Manes
smanes at magpie.com
Sun Jul 22 23:55:40 EDT 2007
David Krings wrote:
> I'm getting back the rows that I want, but not in the correct order and
> only by using DISTINCT, which I once was told is a nono and not needed
> if I'd just do it right.
> My attempt to output the columns that contain the values the reocrds are
> to get sorted on ends up in being a cartesian join, which barfs up 1248
> rows instead of the 26 I epxect.
Without seeing the actual SQL query it's impossible to guess where the
problem is. In general though, cartesian joins are the result of
incomplete join conditionals and, sometimes, overly-complex WHERE
clauses in cases where a left join or sub-select would be more reliable.
The classic cartesian join:
SELECT * FROM users, orders;
More information about the talk
mailing list