Strange phenomenon of the Access database Update statement

Source: Internet
Author: User
When I write an Update query on Access today, I accidentally
Update employee set status = 1, name = 'sind' where id = 99
Write
Update employee set status = 1 and name = 'sind' where id = 99
Result The status field is updated to 0,
I was surprised. How could it be 0? I am not very familiar with Access.
Called a colleague. He looked at it and said "Access" Regards and name = 'sind' as a Boolean statement,
After discussion, I wrote down my understanding:
Brackets are added here for your understanding.
Update employee set status = (1 and (name = 'sink') where id = 99
Because the name in the row with id 99 is not equal to 'sinsink', the result of name = 'sink' is false,
True is interpreted as-1 or 1 () by access (),
(Or-1 or 1 is equivalent to true here ),
False is equivalent to 0 (may be related to C ),
So the result of (name = 'sink') is false,
1 and false are equivalent to true and flase,
So the result is false. If it is converted into Int, It is 0, and then it is updated to 0,
The and character is converted into a logical operator.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.