MySQL data type and where condition

Source: Internet
Author: User

Common data types in MySQL

one, character type
①char (n): fixed N-character length string, if the length is not enough automatic space to be padded; Range of N 0~255
②varchar (N): Storing variable-length strings, most commonly
③text: Storing variable-length strings (often used to publish large pieces of content such as articles)
④tinytext:0~2^8-1 *10
⑤mediumtext:0~2^24-1 *10^3;
⑥longtext:0~2^32-1 * 10^4;
Second, shaping:
①tinyint: Unsigned 0~2^8-1 signed -2^7 ~ 2^7-1;
②smallint: Unsigned 0~2^16-1 signed -2^15 ~ 2^15-1;
③mediumint: Unsigned 0~2^24-1 signed -2^23 ~ 2^23-1;
④int: Unsigned 0~2^32-1 signed -2^31 ~ 2^31-1; Most commonly used
⑤bigint: Unsigned 0~2^64-1 signed -2^63 ~ 2^63-1;
Third, floating-point type
①float: can be accurate to 7 digits after the decimal point number
②double: Can be accurate to 15-16 digits after the decimal point number
Iv. Date-time data type
Note: Because the time store uses a string or timestamp store, the date type is virtually unused in the database
①date (expr): Storing date and time data
② ' TIMESTAMP ' (expr): more accurate than date;

[Common where condition judgment] Relational Operations >,<,=,>=,<=

Logical operation not and OR
Isnul (field) detection is empty
Select*from tb1 WHERE ISNULL (age); All users who are empty
Between. and.. Between two values
Select*from tb1 WHERE ISNULL age between and 14; equivalent to age>=10 and age<=14;
In data between some values
Select*from tb1 WHERE ID in (1,2,3,4,5);
Like similar match
① similar matches when using% to denote any number of characters (0 to more);
Select*from tb1 where username like "Zhang%"; "% Zhang" with a sheet; "% of%", any position containing the sheet
For similar matches, use _ to denote the number of characters;
Select*from tb1 WHERE Username like "_ Two"; The second word is two;
7.EXISTS subquery: EXISTS returns TRUE if the subquery statement >=1 rows with the returned data, otherwise false is returned;
If TB2 returns at least one row of data, the condition is set
8.ALL (subquery), the data returned by the subquery needs to be fully met in order to
The user name cannot be equal to, and the subquery returns any one of the list of user names
9.ANY (subquery) subquery returns data that satisfies one and can be established
User name equals subquery returns any one of the list of user names;
Delete data from a table

MySQL data type and where condition

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.