/*
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