mysql面试题sql语句
时间: 2023-09-23 07:07:37 浏览: 71
以下是一些常见的 MySQL 面试题 SQL 语句:
1. 查询表中所有记录:
```
SELECT * FROM table_name;
```
2. 查询表中指定字段的记录:
```
SELECT column1, column2, ... FROM table_name;
```
3. 按条件查询表中记录:
```
SELECT * FROM table_name WHERE condition;
```
4. 按条件查询表中指定字段的记录:
```
SELECT column1, column2, ... FROM table_name WHERE condition;
```
5. 对查询结果进行排序:
```
SELECT * FROM table_name ORDER BY column_name [ASC|DESC];
```
6. 对查询结果进行分组:
```
SELECT column1, column2, ... FROM table_name GROUP BY column_name;
```
7. 对查询结果进行计数:
```
SELECT COUNT(*) FROM table_name;
```
8. 对查询结果进行求和:
```
SELECT SUM(column_name) FROM table_name;
```
9. 对查询结果进行最大值或最小值的计算:
```
SELECT MAX(column_name) FROM table_name;
SELECT MIN(column_name) FROM table_name;
```
10. 对查询结果进行多表联合查询:
```
SELECT * FROM table1 JOIN table2 ON table1.column_name = table2.column_name;
```
阅读全文