> ## Documentation Index
> Fetch the complete documentation index at: https://villagesql.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# MySQL 教程

> 针对 Sakila 示例数据库，一次一课地学习 MySQL。每一课给出语法、详细示例，以及服务器返回的输出。

本教程按顺序、一次一课地教您在 MySQL 上使用 SQL。每一课都查询同一个示例数据库，所以每一课都建立在您已经加载的数据之上，而不是另造新表。显示的每个结果都是从运行中的服务器捕获的输出，所以您可以把屏幕与页面对照。

如果您是 SQL 新手，请按顺序阅读。如果您已经会写 SQL，只想为一个问题找到一个答案，MySQL 指南覆盖了同样的内容，但按任务而不是按课程组织。

## 目录

### 环境准备

* [安装服务器](https://villagesql.com/docs/zh/tutorial/install-mysql.md)
* [Sakila 示例数据库](https://villagesql.com/docs/zh/tutorial/sakila-database.md)
* [加载 Sakila](https://villagesql.com/docs/zh/tutorial/load-sakila.md)

### 读取数据

* [SELECT](https://villagesql.com/docs/zh/tutorial/select.md)
* [列别名](https://villagesql.com/docs/zh/tutorial/column-aliases.md)
* [ORDER BY](https://villagesql.com/docs/zh/tutorial/order-by.md)
* [SELECT DISTINCT](https://villagesql.com/docs/zh/tutorial/select-distinct.md)
* [LIMIT](https://villagesql.com/docs/zh/tutorial/limit.md)
* [运算符](https://villagesql.com/docs/zh/tutorial/operators.md)

### 筛选行

* [WHERE](https://villagesql.com/docs/zh/tutorial/where.md)
* [AND、OR 和 NOT](https://villagesql.com/docs/zh/tutorial/and-or-not.md)
* [IN](https://villagesql.com/docs/zh/tutorial/in.md)
* [BETWEEN](https://villagesql.com/docs/zh/tutorial/between.md)
* [LIKE](https://villagesql.com/docs/zh/tutorial/like.md)
* [IS NULL](https://villagesql.com/docs/zh/tutorial/is-null.md)
* [REGEXP](https://villagesql.com/docs/zh/tutorial/regexp.md)
* [大小写敏感性](https://villagesql.com/docs/zh/tutorial/case-sensitivity.md)

### 连接表

* [连接的工作原理](https://villagesql.com/docs/zh/tutorial/joins.md)
* [表别名](https://villagesql.com/docs/zh/tutorial/table-aliases.md)
* [INNER JOIN](https://villagesql.com/docs/zh/tutorial/inner-join.md)
* [LEFT JOIN](https://villagesql.com/docs/zh/tutorial/left-join.md)
* [RIGHT JOIN](https://villagesql.com/docs/zh/tutorial/right-join.md)
* [CROSS JOIN](https://villagesql.com/docs/zh/tutorial/cross-join.md)
* [自连接](https://villagesql.com/docs/zh/tutorial/self-join.md)

### 分组与聚合

* [聚合函数](https://villagesql.com/docs/zh/tutorial/aggregate-functions.md)
* [GROUP BY](https://villagesql.com/docs/zh/tutorial/group-by.md)
* [HAVING](https://villagesql.com/docs/zh/tutorial/having.md)
* [COUNT DISTINCT](https://villagesql.com/docs/zh/tutorial/count-distinct.md)
* [GROUP\_CONCAT](https://villagesql.com/docs/zh/tutorial/group-concat.md)
* [WITH ROLLUP](https://villagesql.com/docs/zh/tutorial/with-rollup.md)

### 合并与嵌套查询

* [UNION](https://villagesql.com/docs/zh/tutorial/union.md)
* [子查询](https://villagesql.com/docs/zh/tutorial/subqueries.md)
* [相关子查询](https://villagesql.com/docs/zh/tutorial/correlated-subqueries.md)
* [EXISTS](https://villagesql.com/docs/zh/tutorial/exists.md)
* [ANY 和 ALL](https://villagesql.com/docs/zh/tutorial/any-all.md)
* [派生表](https://villagesql.com/docs/zh/tutorial/derived-tables.md)
* [公用表表达式](https://villagesql.com/docs/zh/tutorial/cte.md)
* [递归 CTE](https://villagesql.com/docs/zh/tutorial/recursive-cte.md)

### 修改数据

* [INSERT](https://villagesql.com/docs/zh/tutorial/insert.md)
* [插入多行](https://villagesql.com/docs/zh/tutorial/insert-multiple-rows.md)
* [INSERT SELECT](https://villagesql.com/docs/zh/tutorial/insert-select.md)
* [UPDATE](https://villagesql.com/docs/zh/tutorial/update.md)
* [DELETE](https://villagesql.com/docs/zh/tutorial/delete.md)
* [Upsert](https://villagesql.com/docs/zh/tutorial/upsert.md)
* [事务](https://villagesql.com/docs/zh/tutorial/transactions.md)

## 您需要什么

一台运行中的服务器、加载到其中的 Sakila 示例数据库，以及一个客户端。"环境准备"一节涵盖全部 3 项。

## VillageSQL 的定位

VillageSQL 是加上了扩展框架的 MySQL，所以本教程中的每条语句都可以原样在它上面运行。这里没有任何一课需要扩展。您学完之后，指南会介绍扩展在此之上增加了什么。

MySQL is a registered trademark of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners. VillageSQL is not affiliated with
or endorsed by Oracle Corporation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.