数据库增添
條件查詢用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/qwer123666/p/7083269.html
總結
- 上一篇: 使用Pycharm的一些错误
- 下一篇: Redis命令总结及其基础知识讲述