I have this sqlite column:
USA
Russia
Japan
and I need have two columns like this:
USA Russia
USA Japan
Russia USA
Russia Japan
Japan USA
Japan Russia
How can i do it?
CodePudding user response:
Just join
select t1.country, t2.country
from myTable as t1
join myTable as t2 on t1.country != t2.country
CodePudding user response:
You need a self join of the table based on the inequality of the columns:
SELECT t1.col AS column1,
t2.col AS column2
FROM tablename t1 INNER JOIN tablename t2
ON t2.col <> t1.col;