數(shù)據(jù)查詢語言DQL
1、單表查詢
(1)全表查詢:select * from 表名;
(2)查詢指定列:select 字段1[,字段2,…] from 表名;
(3)查詢不重復的數(shù)據(jù):select distinct 字段名 from 表名;
(4)設(shè)置別名:select 字段名 as 列別名 from 原表名 [as ]表別名;
(5)條件查詢:select 字段1[,字段2,…] from 表名 where 篩選條件;
(6)空值查詢:select 字段1[,字段2,…] from 表名 where 空值字段 is[ not] null;
(7)模糊查詢:select 字段1[,字段2,…] from 表名 where 字符串字段[ not] like 通配符;
(8)聚合運算:將多行數(shù)據(jù)進行聚集計算為一行,聚合函數(shù)會對null以外的數(shù)據(jù)進行聚合運算
(9)分組查詢:select 字段1[,字段2,…] from 表名[ where 查詢條件] group by 分組字段1[,分組字段2,…];
(10)分組后篩選:select 字段1[,字段2,…] from 表名[ where 查詢條件][ group by 分組字段1[,分組字段2,…]] having 篩選條件;
(11)查詢結(jié)果排序:select 字段1[,字段2,…] from 表名 order by 字段1[ 排序方向,字段2 排序方向,…];
(12)限制查詢結(jié)果數(shù)量:select 字段1[,字段2,…] from 表名 limit [偏移量,] 行數(shù);
2、多表查詢
(1)連接查詢
(2)內(nèi)連接
(3)左連接
(4)右連接
(5)笛卡爾積
(6)自連接
3、合并查詢
(1)union去重:select 字段1[,字段2,…] from 表名 union select 字段1[,字段2,…] from 表名;
(2)union all不去重: select 字段1[,字段2,…] from 表名 union all select 字段1[,字段2,…] from 表名;
4、子查詢
一個select語句中包含另一個或多個完整的select語句
5、常用函數(shù)
(1)字符串函數(shù)
(2)數(shù)學函數(shù)
(3)日期時間函數(shù)
(6)開窗函數(shù)
(7)序號函數(shù)








暫無數(shù)據(jù)