继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

sql server学习(从0到1)

三千无畏
关注TA
已关注
手记 1
粉丝 6
获赞 60

select 表里的XXX,xxx,xxx
from 查询XX表

order by XX desc 大到小倒叙 (不填就是正序123456)

可以order by name desc,id(名字倒叙,id正序排表)

isnull(id,'')把id这行的null空显示为空格( )不用

显示为(null)

isnull(id,'')as id123(as之后是给他起一个新名字方面显

示好看)

where 条件语句,什么=什么。什么大于小于什么
=‘列里的某个东西,如暴雪公司’

where XX=5 and xxxxx>15 并列,一起
between '5' and '999'之间

='5' and <'444'大于5小于444

where name = '奥特曼'字符的用''弄起来。名字为奥特曼

where name like '%周%' 有周这个(周前后大概查找,模

糊查询)

'xxx%'也行、有;两个单词

where age in ('12','50')岁数里找12和50岁的
not in 不是XX的

size is null是null
size is not null不是null

where color ='white' or color ='black' 颜色有白或者

黑的都有
where color ='white' and color ='black'两个都同时存

在才行

where (id=199 or id=10) and name='周'(id是199或10的

名字叫周的人)

distinct 第一无二的,唯一的
count(distinct(id))总计有多少id
avd()1。
min()2。
max()3。
sum()4。

max(age)唯一的值,只能用xxx()才行其他要加groupby
普通的但要放group bu里才可以
select id,max(age) as Mage
from XXX
group by id 才行
order by id 排序

having 后加1。2。3。4。才行,不能用于普通,如max

(age)>10 最大岁数大于十岁

打开App,阅读手记
10人推荐
发表评论
随时随地看视频慕课网APP