开发者

convert negative value to zero in mysql

When the value of an uns开发者_运维问答igned field becomes negative it becomes a very big positive number. I use a query like this:

UPDATE table SET foo=foo+bar

I want it to become a zero when it gets negative instead of that.


UPDATE table SET foo = GREATEST(foo+bar, 0)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜