简单的SQL语句的增、删、改、查
1、增: insert into 表名 values();                //添加⼀整⾏数据
insert into 表名(sno) values(xx);    //对对应的列添加数据
2、改: update 表名 set sno=xx;                默认修改所有的数据
update 表名 set sno=xx where uname=xxx;  只会修改uname为xxx的⾏
3、删: delete from 表名;                                        删除所有的数据
delete from 表名 where uname=xxx;        只会删除uname为xxx的⾏
4、查:
select * from 表名;              查⼀个表⾥⾯所有的数据
select uname from 表名;    查⼀个表⾥⾯所有列为uname的数据
select * from 表名 where age>18;                        查询出所有年龄⼤于18岁的数据
select * from 表名 where age>18 and sex='男';    查询出所有年龄⼤于18岁的男性的数据
select * from 表名 where age>18 or sex='男';      查询出所有年龄⼤于18岁的,或者男性的数据
select * from 表名 group by xxx;        以xx为分组查询,只会查出这⼀列的所有的不同的值,并且,只有⼀⾏数据            select * from 表名 order by xxx asc;  排序, 根据xxx来排序    asc从低到⾼      desc从⾼到低
select * from 表名 limit x,y;                limit限制查询结果的数量
如果只有⼀个参数,那么代表从1开始,返回x条数据
如果有两个参数,代表从x开始,查询y条数据sql中delete用法
当sql语句分组或者排序之后,就不能有条件了,如果想加条件,则⽤having
要求年龄⼩于35岁才进⾏分组
select * from 表名 group by sex where age<35;
select * from 表名 group by sex having age<35;
案例:查出消费最⾼的那个⼈
select * from 表名 order by price desc limit 1;

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。