mysql中 下边这句话怎么改能成功呢
update category set country=(
select xx.country from (
select * from category where parentid=left(parentid,8) and country=''
)xx
);
[Err] 1242 - Subquery returns more than 1 row
我知道啥意思 就不会修改
这是在一个表内的相同字段关联,因为有的country不是空的 我要把为空的country通过parentid关联起来 然后把country更新。
update category set country=(
select xx.country from (
select * from category where parentid=left(parentid,8) and country=''
)xx
);
[Err] 1242 - Subquery returns more than 1 row
我知道啥意思 就不会修改
这是在一个表内的相同字段关联,因为有的country不是空的 我要把为空的country通过parentid关联起来 然后把country更新。
select xx.country from (
select * from category where parentid=left(parentid,8) and country=''
)xx
);
update category A,category B
set A.country=B.country
where B.parentid=left(A.parentid,8) and B.country=''
update category A,category B
set A.country=B.country
where B.parentid=left(A.parentid,8) and B.country='';
select xx.country from (
select * from category where parentid=left(parentid,8) and country=''
)xx
);
select min(xx.country) from (
select * from category where parentid=left(parentid,8) and country=''
)xx
);
update category a ,
(select * from category where parentid=left(parentid,8) and country='') b
set a.country=b.country