Insert Into时,需要计算一个值,但是当值小于5时,就插入5怎么办?
一个语句是:
insert into a (feiyong) values(zijin * feilv);
但是当zijin*feilv小于5时,按5插入,怎么办?
[解决办法]
insert into a (feiyong) select case when zijin * feilv <5 then 5 else zijin * feilv end
[解决办法]
insert into a (feiyong) select case when zijin * feilv < 5 then 5 else zijin * feilv end
[解决办法]
insert into a (feiyong) values(case when zijin * feilv<5 then 5 else zijin * feilv end)