模糊查询
select *
from 表
where 列
like '开头%' 或 '%结尾';
内连接
方法一
select 需要显示的列
from A表 , B表 , C表 ···
where A表的列 = B表的列 and B表的列 = C表的列 and ··· and 条件;
方法二
select 需要显示的列
from A表
inner join B表 on A表的列 = B表的列
inner join C表 on B表的列 = C表的列 and 条件
where 条件;
去重
distinct
select distinct 需要显示的列
from 表
where 条件;
分组
group by
select *
from 表
where 条件
group by 列 ;
排序
oder by
-- 从小到大 asc 可以省略不写
select *
from 表
order by 要排序的列 asc;
-- 从大到小
select *
from 表
order by 要排序的列 desc;
常用函数
count() 计数
sum() 求和
avg() 求平均值
max() 求最大值
min() 求最小值
select 需要显示的列 , count(*)
from 表,表,表···
where 条件;
分页
limit 函数有两个参数,第一个是起点,第二个是一些显示的条数
select *
from 表
limit (显示从第几个开始x+1)x , (显示几个数据y) y;
本文介绍了SQL中的模糊查询、内连接操作、去重、分组、排序以及常用函数,包括count(), sum(), avg()等,并讲解了如何实现分页和数据处理的基本方法。同时涵盖了数据库连接、数据操作和分析的关键知识点。
1万+

被折叠的 条评论
为什么被折叠?



