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

2025-04-18 02:07:14

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

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢