如图、、
在tab1中,fid是父栏id,如宜昌武汉的fid都是1,现在已知tab1中的aid为3,怎么查询表tab1得出湖北的tongji字段如何查处aid是3的父栏的tongji字段。
------解决方案--------------------
sql codeselect t1.tongji from tab1 t1 left join tab1 t2 on t1.aid=t2.faid where t2.aid=3
------解决方案--------------------
查询湖北的tongji字段:
select tongji from tab1 where area='湖北'
查询aid是3的父栏的tongji字段
select tongji from tab1 where aid in (select faid from tab1 where aid=3)
