What is the bit type in MySQL?

Source: Internet
Author: User
MySQL bit type! What better method do you have? If there are only two types of promised data in MySQL, when setting its data type, we will first think of bit, which occupies less characters, is fast, and really cool! When this data type is inserted, the value 1 changes to an icon (like a smiling face, which can be viewed on the mysql client), and the value 0 changes to a blank (probably ignored ), mySQL still knows them, so there is no problem in using SQL queries in MySQL. When it is Php, it is not known. If the data value retrieved on the page is compared with 1 or 0, the result is false!

1. The output on the page is 'R', and 0 is blank!

Test with ord () to obtain their differences,

Bit type: 1 ord (): 1 // acⅱ code of 'R'

Bit Type 0 ord (): 0

I don't know if you can do anything. It's better to know more!

Also: Why does MySQL store the bit type like this? MSSQL does not change this type!

Bit processing is troublesome. You can use it as an integer during query.
Select cast ('mybitfield' as signed) from test
This way in PHP can be compared with the integer number. From: http://www.phpchina.com/html/69/t-46369.html
Related Article

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.