2022/12/1
将一个表中一列替代另一个表的一列
update a
set dh= (select phone from b where b.name=a.name );
出现了报错如下
more than one row returned by a subquery used as an expression
括号里面的SQL应该返回一个结果,这里返回了多个,导致最终的SQL匹配不上。
解决办法:在返回多个值的问题SQL上添加limit 1 限制即可。
update a
set dh= (select phone from b where b.name=a.name limit 1 );
2.查询表结构报错
mysql> show columns from 表名;
ERROR 1142 (42000): SELECT command denied to user ‘root’@‘localhost’ for table ‘user’
这个是没有被赋权,赋权后就可以了