修改表中数据
UPDATE people set name='阿二' where id=123456798;
删除表中数据
DELETE FROM people where id=111;
修改和删除如果不加where是修改或删除所有数据。
(DQL)
一、单表查询:
查people表里所有数据:
select * from people
查people表里人名和年纪;
select name ,age from people;
不重复查询年纪
select DISTINCT age from people;
查询年纪为10的人和他所有信息
select * from people where age='10';
查找年纪不在10和18岁的人
select * from people where age not in('10','18');
查以id是89结尾的人
select * from people where id like '%89';
98%是以98开头,%98%含有98就可以。
双条件:
select * from people where id like '%89' or age='10';
and都符合,or符合其一。
id降序排序:
select * from people ORDER BY id desc;
性别升序,id降序
select * from people ORDER BY gender asc, id desc;
表中一共几行数据
select count(*) from people;
性别去重后,表中一共几行数据
select count(DISTINCT gender) from people;
查询表中一共几行数据,并按年纪分组
select count(*) from people GROUP BY age;
以上条件+打印出年纪
select count(*),age from people GROUP BY age;
只统计age为10的数据一共有几条
select count(*) from people GROUP BY age having age='10';
只查询表前三行数据:
select * from people limit 3
分页查询,前三行数据一页:
select * from people limit 0,3;
后三行一页:
select * from people limit 3,3;
本文发布于:2024-02-02 19:00:22,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170687162045795.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |