手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

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

时间:2024-10-13 08:17:20

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

© 手抄报圈