【发布时间】:2022-01-11 13:52:16
【问题描述】:
我在我的 mysql 8.0 数据库上使用了一个表引用:
update station_temp_data a
set min_temp = (select min_temp from
( select min(air_temp) as min_temp
from station_temp_data b
where b.station_id = a.station_id
and DATE_FORMAT(b.mdate, "%Y.%m.%d") = DATE_FORMAT(a.mdate, "%Y.%m.%d")) as Q1)
这在 mysql 8.0 上可以正常工作,但在 5.5 上不行!
我在 5.5 上报错:
Error : Unknown column 'a.station_id' in 'where clause'
如何将此 SQL 降级到 5.5 版本?
【问题讨论】:
-
您必须使用多表 UPDATE,而不是相关子查询。在提到的两个版本中。
-
太棒了!你有示例链接吗?
-
我投票结束这个问题,因为这个问题与编程无关
标签: mysql