If I have a table that I\'d like to cross join to itself, how can I remove the duplicate rows? Or to put it another way, how can I do a \"order doesn\'t matter\" cross join?
T as t1
inner join
T as t2
on t1.field < t2.field
FWIW, you can just use INNER JOIN
for this, it's not strictly a CROSS JOIN
. MySQL (and perhaps some other RDBMS) treats these two types of join as identical, but in ANSI SQL, a cross join has no join condition -- it's a deliberate Cartesian product.