SQL查询检查可用房间时出错


Error SQL query Checking Available Room

每个人。我在网上预订酒店的任务上有问题,所以我有很多桌子,比如:

tbRoom(RoomID,RoomName,...)
tbReservation(ResID,ResDate,....)
tbReservationDetail(ResID,RoomID,ArrvialDate,DepartureDate,....)

我的问题是当我像这样写sql查询时出错。

Select * from tbRoom as R where R.RoomID !=(select RD.RoomID from tbReservationDetail as RD where ArrivalDate < '2013-12-20' AND DepartureDate > '2013-12-17')

它的错误:

unknown table status: TABLE_TYPE

我的目的是:我想在两次约会之间订一个房间。

那么,我该怎么办?

请帮帮我,谢谢你的帮助。。。。

您可以尝试使用:

Select * from tbRoom as R where R.RoomID NOT IN (select RD.RoomID from tbReservationDetail as RD where RD.ArrivalDate < '2013-12-20' AND RD.DepartureDate > '2013-12-17')

解释:首先,您应该使用NOT IN而不是=,因为您的子查询是列表,其次,在子查询中,您应该在WHERE条件中使用表别名RD

使用not in代替!=,不需要命名表

Select * from tbRoom where RoomID not in (select RoomID from tbReservationDetail where ArrivalDate < '2013-12-20' AND DepartureDate > '2013-12-17')

您必须将phpadmin版本更新到3.4.0phpmyadmin中的错误更新版本,它将解决您的问题