select a.?,b.?,c.? from 楼字表 a inner join 房屋号 b on a.楼字代号=b.楼字代号 inner join 收费明细表 c on b.房间代号=c.房间代号 where a.楼字代号=?
采用关联查询: select C.小区代号, C.楼宇代号, B.房间代号, A.房主姓名, A.费用 from 收费明细表 as A left join 房屋表 as B on A.房间代号= B.房间代号 left join 楼宇表 as C on C.楼宇代号= B.楼宇代号 where C.小区代号 = '001'
select 你要的列 from 楼宇表 A,房屋表 B,收费明细表 C where A.楼宇代号=B.楼宇代号 and A.房间代号=B.房间代号 and 你的其他条件
to CrazyFor(蚂蚁) : Top关键字是不是不能使用在嵌套的select语句中???
Top关键字是不是不能使用在嵌套的select语句中??? 答:完全可以 eg: select * from (select top 10 * from school) temp
当然可以用:select top 10 * from (select * from(select top 10 * from syscolumns) a) b
select 你要的列 from 楼宇表 A,房屋表 B,收费明细表 C where A.楼宇代号=B.楼宇代号 and A.房间代号=B.房间代号 and 你的其他条件
select 你要的列 from 楼宇表 A,房屋表 B,收费明细表 C where A.楼宇代号=B.楼宇代号 and A.房间代号=B.房间代号 and 你的其他条件
to zjcxc(邹建) : 必须要嵌两层吗? 我写成这样不行: select top 5 * (select * from mytable where id=1) a但是写成这样就可以: select top 10 * from (select * from (select top 10 * from cost_class) a) b
select C.小区代号, C.楼宇代号, B.房间代号, A.房主姓名, A.费用
from 收费明细表 as A left join 房屋表 as B
on A.房间代号= B.房间代号 left join 楼宇表 as C
on C.楼宇代号= B.楼宇代号
where C.小区代号 = '001'
where A.楼宇代号=B.楼宇代号 and A.房间代号=B.房间代号
and 你的其他条件
Top关键字是不是不能使用在嵌套的select语句中???
答:完全可以
eg: select * from (select top 10 * from school) temp
where A.楼宇代号=B.楼宇代号 and A.房间代号=B.房间代号
and 你的其他条件
where A.楼宇代号=B.楼宇代号 and A.房间代号=B.房间代号
and 你的其他条件
必须要嵌两层吗?
我写成这样不行:
select top 5 * (select * from mytable where id=1) a但是写成这样就可以:
select top 10 * from (select * from (select top 10 * from cost_class) a) b