Mysql bit operation

Source: Internet
Author: User

Mysql bit operation

1. MOD (X1, X2) calculates the remainder and returns the same remainder as "%" 2. X1 DIV X2 returns the operator for Division. The same as "/" 3. If the divisor is 0, the result is NULL. 4. <=> and = are the same. They are used to determine whether the operands are equal. The difference is that <=> can be used to judge null, = cannot judge null. Example: select null <=> null result 1 logical operator 1, and & or and: When all operands are not 0 and not null, the result is 1, if any operand is 0 and the result is 0, and one operand is null and no operand is 0, null is returned. Example: a,-1 & 2 & 3 results: 1 B, 0 & 3 Results: 0 c, 0 & null results: 0 d, 3 & null results: null2, or | or, for example: a, 1 |-1 | null | 0 result 1 B, 3 | null result 1 c, 0 | null result null d, null | null result null e, 0 | 0 result 03, non! Or not example: ,! Null result null4, exclusive, or xor: if the same value is 0, the value is 1. If any of the operands is null, null is returned. All numbers greater than-1 and less than 1 in mysql are regarded as logic 0, while other numbers are regarded as logic 1. example: a, null xor 1 result null B, null xor 0 result null c, 3 xor 1 result 0 d, 1 xor 0 result 1 e, 0 xor 0 result 0 f, 3 xor 0 result 1: bitwise AND | bitwise OR ~ Bitwise inversion ^ bitwise XOR or <bitwise left shift> the bitwise right shift operation first converts the operand to the binary number, and then performs bitwise operations, finally, convert the calculation result from binary to decimal. Note: bitwise operators must be in decimal format. If they are binary or octal values, you must use the CONV () function to convert the operands to decimal values. To perform bitwise operations.

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.