省市縣三級自身一對一關聯的表,聯動查詢SQL

select t3.name1,t3.name2,t4.name from 
(select t1.code code1,t1.name name1,t1.parentcode parentcode1,t2.code code2,t2.name name2,t2.parentcode parentcode2 
from t t1 left join t t2 on t1.code=t2.parentcode where t1.parentcode=0) t3 left join t t4 on t3.code2=t4.parentcode
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章