## 简介
常见的SQL语句优化记录。
<!-- more -->
## Not in
- MySQL
模拟需求:查询没有班级的学生(可能在数据量)
一般语句:
```sql
select id from user_table where not in (select user_id from class_table);
```
优化语句
```sql
select a.id from user_table a left join class_table b on a.id - b.user_id where b.user_id is not null;
```
## 须知:本文不定期更新
<div class="article-ads"></div>