开发者

MySQL invert a column with single query

Is it possible to开发者_运维问答 invert a boolean column with just one query?


UPDATE `tablename` SET columname = !columname


try

SELECT IF (MyBoolean, 0, 1) FROM MyTable;

OR

UPDATE MyTable SET MyBoolean = IF (MyBoolean, 0, 1);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜