首先在tableA的age字段加一条重复的记录
insert into tableA values('105','john','25');
目前在age字段中有两个’25’,现在使用过滤查询函数,将重复的记录过滤掉
Select distinct 字段名 from 表名;
select distinct age from tableA;
4、 模糊查询
%在前表示以关键字结尾,%在后表示以关键字开头,两边都有%表示关键字在中间。
SELECT * FROM 表名 where 字段名 LIKE ‘XX%’;
SELECT * FROM 表名 where 字段名 LIKE ‘%XX’;
SELECT * FROM 表名 where 字段名 LIKE ‘%XX%’;
SELECT * FROM tableA where name LIKE 'Ja%';
SELECT * FROM tableA where name LIKE '%ck';
SELECT * FROM tableA where name LIKE '%ac%'; 
5、SQL函数
Count统计字段记录个数
Select count(字段名) from 表名;
select count (age) from tableA;
Sum求和
Select sum(字段名) from 表名;
select sum (age) from tableA;
max求最大值
Select max(字段名) from 表名;
select max (age) from tableA;
min求最小值
Select min(字段名) from 表名;
select min (age) from tableA;
avg求平均值
Select avg(字段名) from 表名;
select avg (age) from tableA;
为了便于理解,现在将两张表画出来
tableA
| ID | Name | Age |
| 101 | Jack | 25 |
| 102 | mike | 22 |
| 103 | amy | 23 |
| 105 | john | 25 |
tableB
| ID | Class | Grade |
| 101 | 3 | 1 |
| 104 | 4 | 2 |
| 105 | 3 | 2 |
