gpt4 book ai didi

当我尝试连接两个表时,Mysql 抛出 "Unknow column column_name in on clause"错误。

转载 作者:行者123 更新时间:2023-11-29 14:01:26 25 4
gpt4 key购买 nike

我试图从下面两张表中显示不同的低价酒店房间(低价房间的酒店,无需显示该酒店的其他房间)。但我收到错误“未知子句中的列column_name”。请检查我的查询

    SELECT  r.*,h.*
FROM hotels_temp h,rooms_temp r
INNER JOIN
(
SELECT
hotel_code,MIN(amount) mincost
FROM
rooms_temp
GROUP BY hotel_code
) m ON r.amount = m.mincost and h.hotel_code=r.hotel_code
ORDER BY r.amount
LIMIT 30

表名称:hotels_temp

enter image description here

表名称:rooms_temp

enter image description here

最佳答案

我可以通过以下查询自己解决这个问题。

    SELECT * FROM hotels_temp
INNER JOIN
(
SELECT r.amount,r.hotel_code FROM rooms_temp r
INNER JOIN
(
SELECT hotel_code,amount, MIN(amount) mincost FROM rooms_temp GROUP BY hotel_code
) m ON
r.amount = m.mincost GROUP BY r.hotel_code
) ht ON
ht.hotel_code=hotels_temp.hotel_code LIMIT 0,30

关于当我尝试连接两个表时,Mysql 抛出 "Unknow column column_name in on clause"错误。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15003481/

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