创建MySQL数据表
CREATE TABLE table_name (column_name column_type);
DROP TABLE table_name ;
INSERT INTO table_name ( field1, field2,...fieldN ) VALUES ( value1, value2,...valueN );
SELECT column_name,column_name FROM table_name [WHERE Clause] [LIMIT N][ OFFSET M]
SELECT field1, field2,...fieldN FROM table_name1, table_name2... [WHERE condition1 [AND [OR]] condition2.....
UPDATE table_name SET field1=new-value1, field2=new-value2 [WHERE Clause]
DELETE FROM table_name [WHERE Clause]
SELECT field1, field2,...fieldN FROM table_name WHERE field1 LIKE condition1 [AND [OR]] filed2 = 'somevalue'
SELECT expression1, expression2, ... expression_n FROM tables [WHERE conditions] UNION [ALL | DISTINCT] SELECT expression1, expression2, ... expression_n FROM tables [WHERE conditions];
expression1, expression2, … expression_n: 要检索的列。
SELECT field1, field2,...fieldN table_name1, table_name2... ORDER BY field1, [field2...] [ASC [DESC]]
SELECT column_name, function(column_name) FROM table_name WHERE column_name operator value GROUP BY column_name;
你可以在 SELECT, UPDATE 和 DELETE 语句中使用 Mysql 的 JOIN 来联合多表查询。 JOIN 按照功能大致分为如下三类:
* INNER JOIN(内连接,或等值连接):获取两个表中字段匹配关系的记录。
* LEFT JOIN(左连接):获取左表所有记录,即使右表没有对应匹配的记录。
* RIGHT JOIN(右连接): 与 LEFT JOIN 相反,用于获取右表所有记录,即使左表没有对应匹配的记录。