ANTON KADACH

Generation

code to explanationWed, 18 Jan 2023

with recursive r as ( select 1 as i,go2.parent_id , goa.id,goa."name",goa."type",goa.postal_code,goa.source_id,goa.external_id,goa.external_ids_history,goa.partition_code,goa.is_deleted,goa.timezone from geo_objects_attributes goa join geo_objects go2 on go2.id = goa.id where goa."type" ='Аобл' union select i+1 as i,go2.parent_id, goa.id,goa."name",goa."type",goa.postal_code,goa.source_id,goa.external_id,goa.external_ids_history,goa.partition_code,goa.is_deleted,goa.timezone from geo_objects_attributes goa join geo_objects go2 on go2.id = goa.id join r on r.id = go2.parent_id ) SELECT* from r JOIN geo_polygons gp ON gp.geo_id = r.id;

selecting geo_objects_attributes where geo_objects_attributes type is region. then selecting geo_objects_attributes where geo_objects_attributes type is city and parent_id is region_id. then repeating this until the last child is found(district)

Questions about programming?Chat with your personal AI assistant