经常使用的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

相关文章
相关标签/搜索