找回密码
 立即注册

推荐阅读

  • 便民服务
  • 关注我们
  • 社区新手
删除
delete===》
delete from meinv where id=2;====》删除plmm2
delete from meinv  where id>=2;===》删除大于等于2
delete from meinv;=====》删除全表数据 接表名
drop table 表名;====》删除表结构和数据
truncate test;====》一次删除全表数据,不能删除部分数据

修改
update 表名 set phone=18322222222 where id=1;===》修改id=1的手机号

查询
select * from 表名;===》查询表中所有数据
select * from 表名 where name="plmm";====》查询name为plmm所有的数据
insert into userl (name)values("plmm"),("plmm1"),("plmm2");===》插入一个name为plmm 系列的数据
select name,phone from 接表名;===》查询单个字段对应的值
select id,phone from  表名 where name="plmm1";====》
select *from 表名 where phone!=13377777777;===》!不等于 查询不等于13377777777的数据
<>也表示不等于
select * from 表名 where phone=13377777777;===》查询手机号等于13377777777的数据
select * from plmm where name="plmm1" and phone=1338888888;===》同时满足多个条件多个条件的时候用and ,查询name为plmm1及phone为13388888888的数据,or是满足其中一个条件。
select * from 表名 where  id between 3 and 6;====》查询某个范围内的数据
select * from 表名 where id>=3 and id>=6;===》查询某个范围内的数据
select * from 表名 where id in(3);====》in=的意思 查询id为3的数据
select * from 表名 where phone in(13377777777,13388888888);===》查询手机号为1337777777,13388888888的数据
select * from 表名 where phone  not in(13377777777);===查询手机号不等于13377777777的数据

select * from 表名 where name like "pl%";=====》查询以pl开头的数据
select * from 表名 where name like "%pl";=====》查询以pl结尾的数据
select * from 表名 where time is null;==》查询为空的数据

select * from 表名 limit 2,4;===》查询第三行到6行的数据
limint m,n  ====》 m=下标 n是行数

排序
asc 从小到大 ---升序
select * from 表名 order by id asc;

dasc 从大到小---降序
select * from 表名 order by id dasc;

select * from 表名 group by class having soce=98;====》通过class字段进行分组,然后加条件soce=98



常用的聚合函数
count()-----统计数量
sum()----求和
avg()-----求平均值
max()----求最大值
min()----求最小值
distinct()-----去重复
select count(*) from meinv;===》统计美女表中数据条数
1·select sum(求哪个字段的和就填哪个字段) from 表名;===》求全部班级分数之和
2·select sum(求哪个字段的和就填哪个字段) from 表名 where class=18;==》求18班班级分数之和

select avg(soce) from 表名;====》求所有人的平均分
select max(soce) from 表名;===》求最大值
select min(soce) from 表名;===》求最小值
select distinct(soce) from 表名===》去重复数据

SZVZ5T_}G`U%((_1XYB.jpg



分享至 : QQ空间
收藏

0 个回复

您需要登录后才可以回帖 登录 | 立即注册