有两张表:第一张表是 room表 中有 roomid(id) room_type(房间类型int类型) roomstatus(房间状态0是隐藏1是显示) 第二张表:roomtype表(房间类型) roomtypeid 与room表中roomtye关联 我想把两个表结合查 :查得问题是:在room表中房间状态为显示的所有房间
[code="sql"]
select a.roomid,a.room_type,a.roomstatus from room a,roomtype b where a.room_type=b.roomtypeid and a.roomstatus='1'
[/code]
[code="sql"]
select a.roomid,a.room_type,a.roomstatus from room a
where a.room_type in
( select b.roomtypeid from roomtype b )
and a.roomstatus='1'
[/code]
不过感觉ls的效率要高点 你试试吧。