您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

关于mysql单一表2次查询语句有关问题

2025/10/16 1:26:27发布19次查看
关于mysql单一表2次查询语句问题
如图、、
在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)

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product