十进制字段的mysql更新语句为NULL或空 [英] Mysql update statement for decimal fields to NULL or emptiness

查看:295
本文介绍了十进制字段的mysql更新语句为NULL或空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知道如何将小数字段更新为空或空.

Can't figure out, how to update decimal field to null or emptiness.

尝试过:

UPDATE ads SET price=NULL WHERE price=0

还有

UPDATE ads SET price="" WHERE price=0

不起作用.

谢谢;)

(更新) 片刻.

推荐答案

UPDATE ads SET price=NULL WHERE price=0

这是将字段设置为NULL的正确方法.但是,如果该列不允许使用NULL,它将无法正常工作.

That is the correct way to set a field to NULL. However it will not work if the column does not allow NULL.

如果您有该表的CREATE语句可用,请检查价格列是否显示NOT NULL.

If you have the CREATE statement for that table available, check if it says NOT NULL for the price column.

如果没有CREATE语句,则可以在oracle或mysql上运行"DESC ads",并查看是否允许使用NULL.

If you don't have the CREATE statements you can run 'DESC ads' on oracle or mysql and see if NULL is allowed.

这篇关于十进制字段的mysql更新语句为NULL或空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆