1.select 語句函數
select number,name from table1;//從「table1」中選擇「number」,「name」兩行;spa
select * from table1;//從「table1」中選擇全部行;orm
select * from table1 where name = "麥當勞麥樂送";//從「table1」中選擇name 爲「麥當勞麥樂送」的紀錄;io
select * from table1 where name like "麥%";//模糊查詢:從「table1」中選擇name以「麥」開始的紀錄(「%麥%」;」%麥「);table
select * from table1 where number = 4008517517 or name = "必勝客宅急送";//從「table1」中選擇number爲「4008517517」或者name爲「必勝客宅急送」的記錄;form
select * from table1 where number = 4008517517 and name = "麥當勞麥樂送";//從「table1」中選擇number爲「4008517517」而且name爲「必勝客宅急送」的記錄;select
select distinct number, name from table1 ;//從「table1」中選擇number或者name均不相同的紀錄(number或者name某一項相同不會被排除);統計
2.統計函數查詢
select sum(Sales) from Store_Information;//全部 Sales 欄位的總合 tab
select count(store_name) from Store_Information;//總共多少個Store_Information
select count(distinct store_name) from Store_Information where store_name is not NULL;//去重而且不爲null(空串照樣統計)Store_Information總共多少個
select sum( Sales) ,store_name from Store_Information where store_name is not NULL and store_name!=" " group by store_name;//統計每一個有店名的店的銷售額
select sum( Sales) ,store_name from Store_Information group by store_name having sum(Sales) >=300;//統計銷售額大於等於300的店
select sum( S1.Sales) StoreSales,S1.store_name StoreName from Store_Information S1 group by S1.store_name having sum(Sales) >=300;//別名機制
3.insert 語句
insert into table1 (number,name) values (4008823823,"真功夫");