SQL Server中三个表两两关联 怎么实现查询??急!!

时间:2026-02-12 18:47:06

select a.*

from 学员表 a

inner join 校区表 b on a.所在学校=b.所在学校

inner join 管理员表 c on b.区域=c.区域

where c.用户名=@用户名 and c.密码=@密码

SQL Server中三个表两两关联 怎么实现查询??急!!

扩展资料

在SQL Server中使用join on 【inner join on】关联多表查询

select cyb.id, xa.name 

from GeneShop.dbo.t_member_cyb cyb 

join GeneShop.dbo.xx_admin xa  on xa.id = cyb.hzjg_id 

join GeneShop.dbo.t_bg bg  on bg.cyb_id = cyb.id 

where (cyb.cybbm=402045 and bg.product_id = 121) or (cyb.cybbm=402070 and bg.product_id = 118)

具体情况若是判断逻辑关系是否正确可以使用如下代码: 

Select dbo.usersinfo.usercode,dbo.ryqxb.usercode,dbo.ryqxb.reportto,b.ename 

FROM DBO.UsersInfo,DBO.UsersInfo B,dbo.RYQXB 

where DBO.UsersInfo.UserCode=dbo.RYQXB.Usercode AND 

dbo.RYQXB.REPORTTO=B.Ename 

参考资料来源:百度百科 - SQL JOIN

© 2026 长短途
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com