gpt4 book ai didi

Mysql查询修改

转载 作者:行者123 更新时间:2023-11-29 22:38:59 26 4
gpt4 key购买 nike

我有一个有效的查询,它在结果中返回 1 行,但是在超过 1 行的结果中我得到:错误代码:1242。子查询返回超过 1 行。

即使有多行,我怎样才能返回所有结果?

代码是:

select numbers 
from vista
where id = (
select b.id + 3 from (
select t1.id, t1.numbers t1val, t2.numbers t2val, t3.numbers t3val
from vista t1
join vista t2 on t1.id = t2.id-1
join vista t3 on t1.id = t3.id-2
where t1.id = (select max(id) - 2 from vista)
) a
join (
select t1.id, t1.numbers t1val, t2.numbers t2val, t3.numbers t3val
from vista t1
join vista t2 on t1.id = t2.id-1
join vista t3 on t1.id = t3.id-2
where t1.id < (select max(id) - 2 from vista)
) b
on a.t1val = b.t1val
and a.t2val = b.t2val
and a.t3val = b.t3val
and a.id <> b.id
)
order by id limit 1;

最佳答案

如果将查询的开头更改为:

select numbers 
from vista
where id in (

最后:

order by id;

查询将返回所有匹配组后面的数字。

See this example.

关于Mysql查询修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29436059/

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