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 T ( idGeo INT IDENTITY(1,1), GEO VARCHAR(64), PARENTID INT ); insert into T (GEO, PARENTID) values ( 'EMEA', NULL), ( 'France', 1), ( 'mIDCAPSfRANCE', 2), ( 'Germany', 1), ( 'France exl midcaps', 2), ( 'Amercias', NULL), ( 'US', 6); select T.idGeo, T.GEO, T1.GEO [GEO Level 1], T2.GEO [GEO Level 2] from T left join T T1 on T.PARENTID = T1.idGeo left join T T2 on T1.PARENTID = T2.idGeo;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear