MYSQL 常用语法
时间: 2024-01-18 10:11:40 浏览: 86
MySQL是一种关系型数据库管理系统,常用于存储和管理数据。以下是MySQL的一些常用语法:
1. 创建数据库:CREATE DATABASE database_name;
2. 使用数据库:USE database_name;
3. 创建表格:CREATE TABLE table_name (column1 datatype, column2 datatype, ...);
4. 插入数据:INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
5. 更新数据:UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;
6. 删除数据:DELETE FROM table_name WHERE condition;
7. 查询数据:SELECT column1, column2, ... FROM table_name WHERE condition;
8. 排序数据:SELECT column1, column2, ... FROM table_name ORDER BY column_name ASC/DESC;
9. 过滤数据:SELECT column1, column2, ... FROM table_name WHERE column_name LIKE pattern;
10. 聚合函数:SELECT function(column_name) FROM table_name;
11. 连接表格:SELECT column_name(s) FROM table1 JOIN table2 ON table1.column_name = table2.column_name;
12. 子查询:SELECT column_name(s) FROM table_name WHERE column_name IN (SELECT column_name FROM table_name);
阅读全文