SQL query to find all pairs of rows where the values in the columns are equal

This technical problem asks for a SQL query to find all pairs of rows in a table where the values in the two columns are equal. The example input and output show what such a query would return.

Problem

Given a table with two columns, write a SQL query to find all pairs of rows where the values in the columns are equal.
Example input:
column1 column2
1 2
2 1
3 4
4 3
5 6
6 5
Example output:
1 2
2 1
3 4
4 3
5 6
6 5

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT * FROM table
WHERE column1 = column2;

/*

The above solution is optimal because it is the simplest solution that will work.

*/

A.I. Evaluation of the Solution

The candidate's solution is correct and demonstrates a level of completeness. The solution solves the problem and is a general approach.

Evaluated at: 2022-11-08 06:16:13