經常使用的sql語句總結之數據處理(DML)

數據處理 DML數據庫

1)增
spa

1.1 增添一條記錄
orm

insert into [表名](,,,,,) values(,,,,,) 排序

1.2 從其它表中拷貝數據ci

insert into [表名]
select .... from [
另外一個表it

where ....table

2)改
update [表名]date

set ..... select

where ....語法

3)刪
delete from [表名] where ....

4)查(最經常使用的數據庫操做)

select ....from ...where ....group by ...having ... order by ...

查找:select * from table1 where field1 like ’%value1%’ ---like的語法很精妙,查資料! 

排序:select * from table1 order by field1,field2 [desc] 

總數:select count * as totalcount from table1 

求和:select sum(field1) as sumvalue from table1 

平均:select avg(field1) as avgvalue from table1 

最大:select max(field1) as maxvalue from table1 

最小:select min(field1) as minvalue from table1

相關文章
相關標籤/搜索