gpt4 book ai didi

mysql - 选择 3 个内部联接的不同列

转载 作者:行者123 更新时间:2023-11-30 23:08:48 25 4
gpt4 key购买 nike

我想在这条sql语句中选择distinct RoomName,我不知道把distinct放在这条sql语句的什么地方。

SELECT Distinct
R.RoomID,R.RoomName,RT.RTypeName,RT.RTypePrice,RB.RBedName,RB.RBedPrice,
G.GalName,G.GalPath

FROM tbRoom as R
INNER JOIN tbRoomType as RT ON R.RTypeID = RT.RTypeID
INNER JOIN tbRoomBed as RB ON R.RBedID = RB.RBedID
INNER JOIN tbGallery as G ON R.GalID = G.GalID
WHERE R.RoomID NOT IN(
SELECT RD.RoomID FROM tbReservationDetail as RD WHERE
RD.ArrivalDate <= '$dep' AND RD.DepartureDate >= '$arr' AND R.RoomID =
RD.RoomID
)

最佳答案

试试这个:

SELECT R.RoomID,R.RoomName,RT.RTypeName,RT.RTypePrice,RB.RBedName,RB.RBedPrice, G.GalName,G.GalPath
FROM tbRoom AS R
INNER JOIN tbRoomType AS RT ON R.RTypeID = RT.RTypeID
INNER JOIN tbRoomBed AS RB ON R.RBedID = RB.RBedID
INNER JOIN tbGallery AS G ON R.GalID = G.GalID
WHERE R.RoomID NOT IN(
SELECT RD.RoomID
FROM tbReservationDetail AS RD
WHERE RD.ArrivalDate <= '$dep' AND RD.DepartureDate >= '$arr' AND R.RoomID = RD.RoomID
)
GROUP BY R.RoomName;

关于mysql - 选择 3 个内部联接的不同列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20703969/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com