MySQL (Part 5)

Source: Internet
Author: User

MySQL (Part 5)

1. bitwise operators

Bitwise operators are used to test, shift, or test bitwise in binary bytes. The bitwise operators provided in MySQL include: bitwise OR (|), bitwise AND (&), shift by bit or (^), shift by bit left (<), shift by bit right (>), and reverse by bit (~)

Operator

Function

|

Bit or

&

Bitwise AND

^

Bitwise OR

<

Shift left

>

Shift right

~

Bitwise Inversion

Bit or (|)

Select 10 | 15, 9 | 4 | 2;

Bit and (&)

Select 10 & 15, 9 & 4 & 2;

Bitwise OR (^)

Select 10 ^ 15,1 ^ 0, 1 ^ 1;

Shift left (<)

Select 1 <2, 4 <2;

Shift right (>)

Select 1> 1, 16> 2;

Bitwise inversion (~)

Select 5 &~ 1;

The value after the bitwise operation of MySQL is a 64-bit unsigned number. The binary value of 1 indicates that the rightmost bit is 1, and the other bits are all 0, the other bits are 1.

Select bin (~ 1 );

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.