i am trying to write a query in mysql, where my table structure is given below
place_id state_id city_id place_name
1 0 0 United States
2 1 0 Alabama
3 0 2 Auburn
32 0 0 Canada
33 32 0 Alberta
34 0 33 Calgary
here i have united states id which is 1, using this id i want to retrieve all the states in united states and the cities of each state. Here,
- if state_id and city_id is 0 then it is a country
- if city_id is 0 then it is a state
- if state_id is 0 then it is a city
- place id is auto_increment
please some one help me, thank you.