gpt4 book ai didi

mysql - 更新内部连接卡住

转载 作者:可可西里 更新时间:2023-11-01 07:35:27 26 4
gpt4 key购买 nike

出于某种原因,此 UPDATE 查询永远挂起。如果我替换为 SELECT - 它会立即得到结果。

UPDATE table1 AS t1
INNER JOIN
(
SELECT count(*) as total, left(number,7) as prefix, outcome FROM table1
where outcome like '%Passed%'
group by prefix
order by total desc limit 200
) AS t2
ON t2.prefix = left(t1.number,7) AND t1.outcome = 'Fail'
SET t1.outcome = '', t1.status = 'NEW'

哪里出了问题?

最佳答案

尝试将 ORDER BYLIMIt 移动到 UPDATE 的末尾。像这样的东西:

UPDATE table1 AS t1
INNER JOIN
(
SELECT count(*) as total, left(number,7) as prefix, outcome FROM table1
where outcome like '%Passed%'
group by prefix
) AS t2 ON t2.prefix = left(t1.number, 7) AND t1.outcome = 'Fail'
SET t1.outcome = '', t1.status = 'NEW'
order by total desc
limit 200;

请参阅 UPDATE 的语法.

关于mysql - 更新内部连接卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15787107/

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