ERROR 1048 (23000): Column 'col' cannot be null 问题

netxuning 2013-04-07 03:59:17
用下边语句企图将innter_table中col字段一一updata给outer_table,

UPDATE outter_table SET col = (SELECT col FROM inner_table WHERE id = outter_table.id);


但出现了ERROR 1048 (23000): Column 'col' cannot be null 的错误,
大概是因为outter_table中有的id,inner_table中不存在造成的。如果是这样的话,该如何修正这个update语句从而规避这个问题?
如果不是我猜测的原因,那会是什么造成的?该如何规避?
...全文
2573 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
netxuning 2013-04-07
  • 打赏
  • 举报
回复
引用 1 楼 wwwwb 的回复:
1、修改此字段可以为NULL; 2、UPDATE outter_table SET col = IFNULL((SELECT col FROM inner_table WHERE id = outter_table.id),1);
版主威武啊 。。。
wwwwb 2013-04-07
  • 打赏
  • 举报
回复
1、修改此字段可以为NULL; 2、UPDATE outter_table SET col = IFNULL((SELECT col FROM inner_table WHERE id = outter_table.id),1);

57,063

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧