mysql中int类型的字段没赋默认值为空时如何使用查询条件

问题:
当int类型的字段没赋默认值为0,当插入数据为空时如何使用查询条件吧为null的数据查出来
错误:
select * from table where a = null ?

正确
select * from table where isNull(a);

把这些值都批量赋0后修改字段的默认值设为0,当下次再查询是判断a = 0即可
update table set a = 0 where isNull(a);

猜你喜欢

转载自blog.csdn.net/m0_49412847/article/details/121394858
今日推荐