首页 > 数据库技术 > 详细

MySQL-SQL查询

时间:2020-02-13 14:34:37      阅读:60      评论:0      收藏:0      [点我收藏+]

1.基础

范围查询

between:select 字段 from 表名 where 字段 between 值 and 值;
select id from stu where id between 1 and 3;
技术分享图片
in:select 字段 from 表名 where 字段 in (值,值);
select id from stu where id in (2,3);
技术分享图片
not in:select 字段 from 表名 where 字段 in (值,值);
select id from stu where id not in (2,3);
技术分享图片

排序

order by asc:select 字段 from 表名 order by 字段;(升序)
select * from stu order by id;
技术分享图片
order by desc:select 字段 from 表名 order by 字段 desc;(降序)
select * from stu order by id;
技术分享图片

去重

distinct:select distinct(字段) from 表名;
select distinct(id) from stu;
技术分享图片

限制

limit:select 字段 from 表名 limit 数字;
select * from stu limit 2;
技术分享图片

MySQL-SQL查询

原文:https://www.cnblogs.com/zhangshan33/p/12303396.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!