我正在尝试为数据库的sql服务器写q查询,在该数据库中检索HotelID和墨尔本所有配有特大号床的酒店的名称,但是字段列表中的HotelID模棱两可,我不知道如何解决此问题?这是我的查询

SELECT      City, BedTypeDesc, HotelName, HotelID
FROM     BedTypes,     Hotels,     Cities,     Rooms
WHERE     Hotels.CityID = Cities.CityID         AND Hotels.HotelID = Rooms.HotelID          AND Rooms.BedTypeID = BedTypes.BedTypeID         AND BedTypeDesc = 'King Size'         AND City = 'Melbourne'

最佳答案

您应该使用正确的join语法表别名:

SELECT c.City, bt.BedTypeDesc, h.HotelName, h.HotelID
FROM Hotels h JOIN
     Cities c
     ON h.CityID = c.CityID JOIN
     Rooms r
     ON h.HotelID = r.HotelID JOIN
     BedTypes bt
     ON r.BedTypeID = bt.BedTypeID
WHERE bt.TypeDesc = 'King Size' AND c.City = 'Melbourne' ;

关于mysql - 一直说错误105,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34689651/

10-11 03:18