Sql Server中一个表2个字段关联同一个表(代码解决)
(编辑:jimmy 日期: 2024/11/15 浏览:3 次 )
复制代码 代码如下:
select a.man_id,man_name,d.sex_name,zw_name,c.money
from man as a
left join zw as b on a.zw_id=b.zw_id
left join zw as c on a.man_id=c.man_id -- 同时关联zw字段,通过表别名区别开
left join xb as d on c.sex_id=d.sex_id
select a.man_id,man_name,d.sex_name,zw_name,c.money
from man as a
left join zw as b on a.zw_id=b.zw_id
left join zw as c on a.man_id=c.man_id -- 同时关联zw字段,通过表别名区别开
left join xb as d on c.sex_id=d.sex_id
下一篇:诊断SQLSERVER问题常用的日志概述及使用