sql的多表联查语句

来源:互联网 发布:杭电网络教学平台 编辑:程序博客网 时间:2024/06/03 16:33


 语法格式可以概括为:
    select * FROM (((表1 INNER JOIN 表2 ON 表1.字段号=表2.字段号) INNER JOIN 表3ON 表1.字段号=表3.字段号) INNER JOIN 表4 ON Member.字段号=表4.字段号) INNER JOIN 表5ON Member.字段号=表5.字段号

 

列子:

select *from (t_roomInfomation  inner joint_roomTypeInfomation on
 t_roomInfomation.type_id=t_roomTypeInfomation.id) inner join t_roomFloorInfomation on
t_roomInfomation.floor_id = t_roomFloorInfomation.id wheret_roomFloorInfomation.id=(select id from t_roomFloorInfomationwhere floor_name='一楼')
and t_roomTypeInfomation.id=(select id from t_roomTypeInfomationwhere roomType='单人间') and status='入住'

 

结果:
id     status  price  type_id  floor_id    id      roomType id   floor_name
1004 入住 100    单人间  一楼

0 0
原创粉丝点击