SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table city( id int auto_increment, name varchar(100), primary key (id) ); insert into city(name) values("москва"), ("якутск"), ("саратов"); select * from (select least(city.id, city2.id) as id1, greatest(city.id, city2.id) as id2 from city join city as city2 on city.id != city2.id group by least(city.id, city2.id), greatest(city.id, city2.id) ) as t join city as city1 on city1.id = id1 join city as city2 on city2.id = id2;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear