全国省市级联sql表
【查询所有的省市区信息】
SELECT * FROM hat_province AS p LEFT JOIN hat_city as c ON p.provinceID = c.father LEFT JOIN hat_area AS a ON c.cityID = a.father;
对于后台获取到数据之后,可以按照以下数据格式返回给前端进行解析:
[
{
"value": "130000",
"label": "河北省",
"children": [
{
"value": "130100",
"label": "石家庄市",
"children": [
{
"value": "130102",
"label": "长安区"
},
{
"value": "130104",
"label": "桥西区"
}
]
},
{
"value": "130200",
"label": "唐山市",
"children": [
{
"value": "130202",
"label": "路南区"
},
{
"value": "130203",
"label": "路北区"
}
]
}
]
},
{
"value": "130000",
"label": "河北省",
"children": [
{
"value": "130100",
"label": "石家庄市",
"children": [
{
"value": "130102",
"label": "长安区"
},
{
"value": "130104",
"label": "桥西区"
}
]
},
{
"value": "130200",
"label": "唐山市",
"children": [
{
"value": "130202",
"label": "路南区"
},
{
"value": "130203",
"label": "路北区"
}
]
}
]
}
]