MySQL Base statement

Source: Internet
Author: User

/*
Because of the current MySQL tools and convenient, such as SQLyog, so in fact, build a database table (or even additions and deletions) only need to operate in such tools, it can also minimize errors.
The following statements will be used only when it is difficult or programmed to use the MySQL tool to prevent errors.

*/

#建立数据库aaa, AAA has a xg_role table, the design table Xg_role as follows:

#mysql在windows中字段名称不区分
#mysql在linux, the field names in Unix are distinguished by
#mysql中 "#" is a single-line comment, and "/* Comment Content */" is a multiline comment.

/*Increase*/INSERT intoXg_role (Name,remark)VALUES('Zhao Liu','Zhao Yun's brother');INSERT intoXg_roleSETNAME="Harry", remark="Superman Armor"INSERT intoXg_roleVALUES('Lee 411', "passers-by"); #该写法除非表中只有两个字段否则是会报错滴/*Delete Delete from table [where] [group] [order] [limit]*/DELETE fromXg_roleWHEREId= One;/*Change the Update table set field = value, field = value [where] [group] [order] [limit]*/UPDATEXg_roleSETNAME="Jewave"WHEREId= 8/*Check*/SELECT * fromXg_role;SELECT COUNT(*) fromXg_role;SELECT AVG(ID) fromXg_role;SELECT * fromXg_roleWHERENAME like '%r'SELECT * fromXg_roleWHERENAME not like'r%'SELECT * fromXg_roleORDER byIdDESC; # (positive order)ASCbecause the default is the general omission of the normal sequenceSELECT * fromXg_roleGROUP byNAME;/*query non-repeating items*/SELECT * fromXg_roleWHEREId>=3 andId<>5#取出id大于等于3且id不等于5的所有行SELECT * fromXg_roleWHERENAME like '%r'LIMIT0,2 /*intercept the first two similar mathematics from the results of the query (0,2]*//*Intercept the first 5 data in the Xg_role table: ID is less than 9 and name is not duplicated and reversed by ID. */SELECT * fromXg_roleWHEREId<9 GROUP byNAMEORDER byIdDESCLIMIT5;

MySQL Base statement

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.