0
多值错误,我跑下面的查询,并得到了错误,您不能指定目标表更新在FROM子句MySQL的子查询返回更新询问
update xyz x
set x.PID = (select c.PPID
from
table1 c where c.FFID
in (select b.FID
from table1 a
join xyz b on a.FFID = b.fID
and a.FFIRD=b.PID and b.flag='4'
group by b.FID
having count(1) =1)
),flag='N'
where x.FID = (select b.FID
from table1 a join xyz b on
a.FFID = b.FID and
a.FFIRD=b.PID and b.flag='4'
group by b.FID
having count(1) =1
)
我提到计算器和改变了我的代码如下图所示。但现在我得到的Subquery返回多于1行。请帮助
update xyz x
set x.PID = (select abc.PPID
from (select c.PPID
from
table1 c
where c.FFID
in (select b.FID
from
table1 a join xyz b on a.FFID = b.fID
and a.FFIRD=b.PID and b.flag='4'
group by b.FID
having count(1) =1
) as abc
),flag='N'
where x.FID = (select xyz.FID
from (select b.FID
from table1 a join xyz b on
a.FFID = b.FID and
a.FFIRD=b.PID and b.flag='4'
group by b.FID
having count(1) =1)as xyz
)
什么是你想在这里做? –
在子查询上它只要求一行返回。要么限制1,要么改变方法。 –