MySQL是一个流行的关系型数据库管理系统,以下是一些基本的MySQL语法:
创建数据库:
CREATE DATABASE database_name;
选择数据库:
USE database_name;
创建表:
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
...
);
插入数据:
INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
查询数据:
SELECT column1, column2, ... FROM table_name WHERE condition;
更新数据:
UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;
删除数据:
DELETE FROM table_name WHERE condition;
选择所有数据:
SELECT * FROM table_name;
条件筛选:
SELECT column1, column2, ... FROM table_name WHERE condition1 AND/OR condition2;
排序:
SELECT column1, column2, ... FROM table_name ORDER BY column1 ASC/DESC;
聚合函数(求和、平均值等):
SELECT COUNT(column1), AVG(column2), SUM(column3) FROM table_name WHERE condition;
分组:
SELECT column1, COUNT(column2) FROM table_name GROUP BY column1;
连接表:
SELECT column1, column2, ... FROM table1 INNER JOIN table2 ON table1.column = table2.column;
删除表:
DROP TABLE table_name;
删除数据库:
DROP DATABASE database_name;