内部连接而没有唯一标识符
在下面的屏幕截图上,您可以看到两个表。在左侧,我有一张带有事故的桌子,在这种情况下,ID是唯一的,并且ID = 68始终是同一事故。
右侧是特定日期温度可用的天气数据。
但是,由于我的案例在一月份存在五个星期六,因此日期并非唯一可识别。 我要做的是在我的第一个“事故”表(空列)中写下温度。
我知道这是一个问题,因为我不想在桌子上发生五次事故(ID = 68应该保持独特)。 即使温度不能100%正确,是否可以加入此数据?我对平均温度感到满意,或者只是使用第一个条目。
这是我的查询,它永远不会停止运行。
UPDATE accident_copy as a
LEFT JOIN wetterdaten as w
ON a.year = w.year
and a.monthDE = w.month
and a.day = w.day
and a.hour = w.hour
SET a.Temperatur = w.Temperatur;
On the screenshot below you see two tables. On the left side I have a table with accidents, in this case the ID is unique and it is always the same accident with ID=68.
On the right side is the weather data available with the temperature of the specific day.
However, the date is not uniquely identifiable since there exists five Saturday's in January in my case.
What I am trying to do, is to write the temperature in my first "Accident" table (empty column).
I know that there is a problem since I don't want to have five times the same accident in my table (id=68 should remain uniquely).
Is there a way to join this data even if the temperature will not be 100% correct? I am happy with an average of the temperature, or just use the first entry.
This is my query, it never stops to run.
UPDATE accident_copy as a
LEFT JOIN wetterdaten as w
ON a.year = w.year
and a.monthDE = w.month
and a.day = w.day
and a.hour = w.hour
SET a.Temperatur = w.Temperatur;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
相反,使用子查询在当时获得平均温度:
Instead use a subquery to get your average temperature for that time: