关于MySQL多表连接查询
程序员文章站
2022-05-29 17:10:43
...
select a.*,c.device_name from device_warn as a
inner join user_warn as b
on a.id=b.warn_id and b.state=1 inner join
device_info as c
on c.DEVICE_ID=a.DEVICE_ID
where a.DEVICE_ID in (select DEVICE_ID from device_station where STATION_ID in (select STATION_ID from station_user where USER_ID=4))
本条sql语句涉及到了三个表的联查,分别是device_warn,user_warn,device_info,
其中,device_warn,user_warn,device_info的表结构分别如下:
易错问题,where条件必须在join条件之后。
上一篇: npm设置淘宝镜像
下一篇: npm安装淘宝镜像和查看镜像设置