开发者

SQL KeyWord Not

开发者 https://www.devze.com 2023-01-26 20:28 出处:网络
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.

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

精彩评论

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