SQL语句总结2018-11-7

时间:2023-12-26 13:29:55

增加一条数据

insert into table (列字段1,列字段2)values(列1值,列2值)

删除一条数据

delete from table where 列名1=值1

修改一条数据

update table set 列名1=值1,列名2=值2 where 列名3=值3

查询一条数据

select 字段1,字段2 from table

去重

distinct   字段名

求和

sum(字段名)

求最大值、最小值

max(字段名),min(字段名)

求平均数

avg(字段名)

按字段排序-升序asc(降序desc)

升序:order by 列字段 asc

降序:order by 列字段 desc

分组

group by 列字段

返回列行数

count(列字段),count(*)

条件关键字

查询字段的值在A到B范围的数据:where 列字段 between A and B

等值条件查询: where 列字段 in(值1,值2,值3...)