SQL基础查询笔记

运行先后顺序
from
on
join
where
group by
with cube or with rollup 不用
having
select
distinct
order by
top

select *from ... 查询所有数据

一条一条数据 筛选 便利的过程

开始位置 from =C# foreach where 筛选条件=foreach{循环体 if 判断} select 映射 抄写* 抄一行 select 到 from 中间 最后运行

top

筛选前多少条

select top 2 *from ...where ..like '%..%'
top 最后运行
like 模糊查询 % _ [] [^]

_ 占用一个字符的位置 可以是任意字符
[] 在这一个字符位置上 可以是中括号范围之内的任何一个
[^]不在什么范围之内的

slelct distinct(去重) brand from ..
distinct 在select 之后

select *from ..order by ..
order by 排序 默认从低到高 asc(可以不写)升序 desc 降序
在select 后边 top在 order by 后边

where 后边筛选
比较运符 < > <= >= !=
逻辑运算符 and or

select *from .. where ..like ..and ..<..

原文地址:https://www.cnblogs.com/zhuxu/p/4870695.html