1. 程式人生 > 其它 >【Linux】CentOS設定伺服器時間timedatectl

【Linux】CentOS設定伺服器時間timedatectl

條件過濾查詢

and  

指的是最小2個以及2個以上的條件成立才叫滿足要求

select * from 表名 where 欄位="欄位值" and 欄位="欄位值";

or

2個或者2個以上滿足其中一個條件舊可以了。

select * from 表名 where 欄位="欄位值" or欄位="欄位值";

 in 包含

括號裡面包含任意一種

select * from tablename  where gender in ("字元",)limit 數字;   limit限制資訊因為太多

between...and查詢範圍

包含開頭和結尾---基本上指查詢a到b之間的數  

大於等於(>=  !=  <=)

正則表示式:

*:代表所有

?:代表一個字串

%:代表一個或者是多個字串

\D:代表的是數字

\d:代表的是字串

以什麼開頭(^)select * from employees where first_name rlike '^christ' limit 5;

以什麼結束 $  select * from employees where first_name rlike '_$' limit 5;

 

 使⽤別名(AS)   select 欄位  as name from table name ; 

函式:實現某一特定的功能;

max():最大 

min():最小 

avg():平均 

 order by :排序

order by 欄位 desc : 倒敘

正序檢視    select *  from table name  order by 欄位  asc;

倒敘檢視  select * from tablename order by 欄位 desc;

 查詢最大   select max(欄位)from  tablename

查詢最小  select min(欄位) from table name;

查詢平均   select avg(平均) from table name;

去重檢視 : select  distinct  欄位 from table name;

                  select distinct  * from table name;

聚合函式

group by

   

檢視平均並排序

檢視平均並排序並過濾         過濾   having 

 1、取出不同年齡段的平均分

2、在這個不同年齡段平均分的基礎上過濾出>50的

3、再對這些大於50的平均分做一個倒序排序

 查詢出店鋪名稱 商品名稱 商品型別 商品價格 級別 地址

 查詢商品目前有多少個

查詢出店鋪名稱,商品名稱,商品型別,價格,還有快遞名稱,電話

having與where的區別:

1. having只能⽤於group by(分組統計語句中)
2. where 是⽤於在初始表中篩選查詢,having⽤於在where和group by 結果分組中查詢
3. having ⼦句中的每⼀個元素也必須出現在select列表中
4. having語句可以使⽤聚合函式,⽽where不使⽤。