Select * from HotelPerson
Where RoomID IN (select ID from HotelRoom Where BookingID = 36 )
Select * from HotelCancelationPolicy
Where RoomID IN (select ID from HotelRoom Where BookingID = 36 )
如何将这两个查询合并为1个查询?
答案 0 :(得分:0)
使用UNION
获取两个表中所有行的不同元素或UNION ALL
Select * from HotelPerson
Where RoomID IN (select ID from HotelRoom Where BookingID = 36 )
UNION ALL
Select * from HotelCancelationPolicy
Where RoomID IN (select ID from HotelRoom Where BookingID = 36 )
答案 1 :(得分:0)
我想你想加入这两个表:
select *
from HotelPerson hp
inner join HotelCancelationPolicy hcp
on hp.RoomId = hcp.RoomId
where hp.RoomID IN (select ID
from HotelRoom
where BookingID = 36 )
答案 2 :(得分:0)
这将为您提供一个表中两个表的所有列。
SELECT *
FROM HotelPerson A, HotelCancelationPolicy B
WHERE A.RoomID = B.RoomID
AND A.RoomID IN (SELECT ID FROM HotelRoom WHERE BookingID = 36)