gpt4 book ai didi

mysql - LIMIT 1 何时返回多行?

转载 作者:行者123 更新时间:2023-11-29 07:01:36 24 4
gpt4 key购买 nike

我在一个更新中有一个相关的子查询,它曾经工作得很好(去年它工作得很好;今年我对架构做了一些小的更改,数据有所不同)。现在它因“子查询返回超过 1 行”错误而失败。

查询是这样的:

update mytable as q
set p_ID = (
select ap.pID
from aptable as ap
where ap.ID = q.ID
and ap.txnDate is not NULL
order by ap.txnDate
limit 1 offset 2
)

很奇怪,嗯?

为了找到返回多行的位置——这应该是不可能的,我准备了查询,添加了“where ap.ID = ?”并针对每个有效 ID 值循环运行查询。你猜怎么着 - 它一直有效。

对这里发生的事情有什么想法吗?

最佳答案

我猜这是因为 Bug #20519: "'Subquery returns more that 1 row' error with 'limit x, 1'" , 已在 MySQL 5.0.25 中修复。

关于mysql - LIMIT 1 何时返回多行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9944312/

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