1.count() 函数 select count (*) from 表名
sum()函数 select sum(字段名) from 表名
avg()函数 select avg(字段名) from 表名
max()函数 select max(字段名) from 表名
min()函数 select min(字段名) from 表名
2.
内连接
tb_login表的user字段与tb_book表的user字段相等
select name,books from tb_login,tb_book
where tb_login.user=tb_book.user;
左外连接
select section,tb_login.user,books,row from tb_login
left join tb_book on tb_login.user=tb_book.user;
右外连接
select section , tb_book.user,books,row from tb_book
right join tb_login on tb_book.user=tb_login.user;
3.子查询
带in 关键字的子查询
select * from tb_login
where user in (select user from tb_book);
带比较运算符的子查询
select id ,books,row from tb_book where row>=(select row from tb_row where id=1);
带exists关键字的查询
select * from tb_row where exists (select * from tb_book where id=27);
带and 关键字的的查询
select books , row from tb_book where row<any (select row from tb_row);
带all关键字的子查询
select books , row from tb_book where row >=all(select row from tb_row);