搜索
您的当前位置:首页正文

sql语句快速入门基础篇

来源:榕意旅游网

一:增删改查

 

 

insert into + 表名(列名字段)value(列名对应值)

如:insert into student(id,name,sex)value('1','小白','男');

delete from +表名 where +条件;

如:delete  from bm_act_spot_check_audit where id = '2612' ;

update +表名 set 列名字段 改为 值 where +条件;

如:update bm_act_spot_check_audit set `city_id`='110100' where `id`='2612' ;

select * from +表名 where + 条件

如:select * from bm_act_spot_check_audit where `rider_name`='测试'  ;

select  列名字段 from +表名 where + 条件 即 只查询 该列数据

如:select act_type from bm_act_spot_check_audit where `rider_name`='测试'  ;

二:常用函数

求平均值 avg(列名字段)

select avg(plan_id) from bm_act_spot_check_audit where `rider_name`='测试' and `act_type`='2' ;

求最小绝对值 min(列名字段)

select min(plan_id) from bm_act_spot_check_audit where `rider_name`='测试' and `act_type`='2' ;

求最大绝对值 max(列名字段)

select max(plan_id) from bm_act_spot_check_audit where `rider_name`='测试' and `act_type`='2' ;

求和 sum(列名字段)

select sum(plan_i

因篇幅问题不能全部显示,请点此查看更多更全内容

Top