有个问题想请教下大家,如果有张表 student,里面有个字段 age,我将 age 默认值设为-1 (表示 null ),能不能通过 mybatis-plus/mybatis/等工具将取出来 age 字段中值为-1 都改为 null 返回。
ps:不考虑 sql 的 IF 函数、手动修改结果返回值
ps:不考虑 sql 的 IF 函数、手动修改结果返回值
|
wysnylcMar 24, 2020
1
可以,真闲
|
|
U7Q5tLAex2FI0o0gMar 24, 2020
3
|
|
yjxjnMar 24, 2020
4
为啥要这么操作呢?建表的时候 age 默认设置成 null 不完事了吗?
|
|
EminemWMar 24, 2020
5
你写个 update 把表里的-1 改成 null 不行吗?
|
|
sgq1128Mar 24, 2020
6
select if(age = -1, null, age) as age from student
|
|
7
为什么要加默认值不设成 null,可以参考这个 https://blog.csdn.net/moqiang02/article/details/42716729
主要还是想找找有没有办法解决我问的问题, 不考虑 if 函数哈 @sgq1128 |
|
botianMar 25, 2020 via Android
8
多此一举。。
|