开发者

SQL KeyWord Not

I have to make a update which shall change a boolean field in a table. If the value is true the value should be set to false and opposite.

Im not sure how the not keyword works in SQL and the following doesnt seem to work:

Update tbl set 开发者_如何转开发field=!field where ID=1


The ! operator is called NOT in SQL. Try this:

UPDATE tbl
SET field = NOT field
WHERE ID = 1

I have verified that this works on PostgreSQL, and it should work on any DB engine worth its salt.


Update tbl set ID=1 where field<>field 

<> is not equal operator in sql

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜