gpt4 book ai didi

mysql - SQL 内连接语法错误

转载 作者:行者123 更新时间:2023-11-29 04:00:09 25 4
gpt4 key购买 nike

我有这个错误。我是 SQL 的新手,无法弄清楚我的语法有什么问题。我将我的 INTERSECT 语句更改为内部连接,意识到 SQL 不接受这种语法。但是我继续收到错误消息。

错误:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use n
ear 'a
INNER JOIN
(Select h.propertyId as id
From House h, has_weather hw, weather_ye' at line 8

该查询假设要查找属性评级等于 5 且 AvgTemp 超过 55 的用户的用户 ID 和电子邮件。

    Select has_property.userId
From has_property
Where has_property.propertyId IN
(
(Select hRR.propertyId as id
From hasRatings_Rate hRR
Where hRR.ratingId = 5
) a

INNER JOIN

(Select h.propertyId as id
From House h, has_weather hw, weather_year wy
Where hw.weatherId = wy.weatherId AND hw.homeAddId = h.homeAddId AND wy.AvgTemp > 55
)b
ON (a.id = b.id)

);

最佳答案

试试这个:

Select has_property.userId
From has_property hp
JOIN hasRatings_Rate hRR ON hp.propertyId = hRR.propertyId
JOIN House h ON h.id = hRR.id
JOIN has_weather hw ON hw.homeAddId = h.homeAddId
JOIN weather_year wy ON hw.weatherId = wy.weatherId
WHERE hRR.ratingId = 5
AND wy.avgTemp > 55

不需要任何子查询,只需一系列连接。

关于mysql - SQL 内连接语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33624182/

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