我正在尝试使用此值插入新行(hotelNo,guestNo,dataform,dataTo,roomNo) 我知道酒店名称,所以我必须从另一张桌子上选择酒店,它没有和我合作,有什么不对吗?
INSERT INTO Booking
VALUES (hotelNo,123,'3-sept-1014','3-sept-1014',121)
(SELECT hotelNo
FROM Hotel
WHERE hotelName='Ritz Carlton' AND city='Dubai');
答案 0 :(得分:5)
从查询中删除VALUES (hotelNo,...
,您就可以了。
INSERT INTO Booking
(SELECT hotelNo,123,'3-sept-1014','3-sept-1014',121
FROM Hotel
WHERE hotelName='Ritz Carlton' AND city='Dubai')
答案 1 :(得分:3)
您应该在没有VALUES
INSERT INTO Booking
(SELECT hotelNo, 123, '3-sept-1014','3-sept-1014',121
FROM Hotel
WHERE hotelName='Ritz Carlton' AND city='Dubai');
答案 2 :(得分:1)
试试这个:
INSERT INTO Booking VALUES (
(SELECT hotelNo
FROM Hotel
WHERE hotelName='Ritz Carlton' AND city='Dubai'),
123,'3-sept-1014','3-sept-1014',121);