update select 同一张表 出现问题
表 note
ID content
1 asjdlsdf
2 asda sewaeawe
3 asdasdasd
现在我有先加了一列 Alter table note add summary char(5)
ID content summary
1 asjdlsdf NULL
2 asda sewaeawe NULL
3 asdasdasd NULL
现在我想将 content 里的前五个字符update到summary 里
如:
ID content summary
1 asjdlsdf asjdl
2 asda sewaeawe asda
3 asdasdasd asdas
MySql语句 我是这样写的:
mysql> update note set summary = ( select left(content,10) from (select * from n
ote group by note.id) as x);
结果报错:Subquery returns more than 1 row
------解决方案--------------------update note set summary = left(content,5);
------解决方案--------------------update note set summary = left(content,5);
------解决方案--------------------update note set summary = left(content,5);