I have a table for my country territorial divisions, which does as follows :
- level 0: country
- level 1: district
- level 2: county
- level 3: parish
(the names were translated on Google)
This levels correspond to a parent => child pseudo relationship that goes as follows:
TABLE zones
id
parent_id
name
Sample data:
VALUES (1,0,'LEVEL 1')
VALUES (2,1,'LEVEL 2')
VALUES (3,2,'LEVEL 3')
So far so good. Now my problem is: how can I select all zones from a certain district (level 1) that are related to it?
This will get all information in joined format:
However if you want to simply list all related zones (not including the district itself, but only county and parishes of that district), you’ll need to use a
UNION: