SQL: self join using each rows only once [duplicate]
问题 This question already has an answer here : Closed 8 years ago . Possible Duplicate: combinations (not permutations) from cross join in sql I've currently got a table with the following records: A1 A2 A3 B1 B2 C1 C2 Where the same letter denotes some criteria in common (e.g. a common value for the column 'letter'). I do a self join on the criteria as follows: SELECT mytable.*, self.* FROM mytable INNER JOIN mytable AS self ON (mytable.letter = self.letter and mytable.number != self.number);