Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
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 AI support!

Copy Clear