数据库增添

条件查询用where

比如:查询Score表中成绩在60到80之间的所有记录。

select DEGREE from score where degree>60 and degree<80

模糊查询用%

比如查询与三相关的数据:

 where cno like '3%'   3%是已三开头   %3%是中间带3  %3是末尾带3

排序查询 order  by desc降序  asc升序   去重查询 distinct 

分组查询group by   联合查询union

 子查询 :

 

查询Score表中的最高分的学生学号和课程号。(子查询或者排序)
select* from score where degree in (select MAX(degree)from score)

聚合函数: max()  min()  avg() count() sum() 

数学函数:ceiling()  floor() round(字段名,小数位)

abs()  pi()

字符串函数:lower() upper() trim() replace(源字段,查找字符)

substring(源字段,索引位置)

转换函数 + 运算,拼接

convert(类型,字段)

cast(字段 as类型)

时间日期函数:

getdate : year(getdate())

dateadd(增加类型,增加量,数据源,dateadd(month,7,getdate())

datename(日期类型,数据源),datename(day,getdate())

 

转载于:https://www.cnblogs.com/yujiamin123/p/7060374.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值