码迷,mamicode.com
首页 > 数据库 > 详细

Mysql 数据查询语句中between and 是包含边界值的

时间:2017-07-17 20:12:31      阅读:4249      评论:0      收藏:0      [点我收藏+]

标签:not   ace   tle   select   条件   tween   bsp   知识   数据   

MySQL的sql语句中可以使用between来限定一个数据的范围,例如:

select * from user where userId between 5 and 7;

查询userId为5、6,7的user,userId范围是包含边界值的,也等同如下查询:

select * from user where userId >= 5 and userId <= 7;

很多地方都提到between是给定的范围是大于等第一值,小于第二个值,其实这是不对的。此前我一直也是这么认为,通过实验,结论是包含两边的边界值,如果实在拿不准,可以采用>= 、<=的方式来指定条件。

另外 not  between的范围是不包含边界值。

Mysql 数据查询语句中between and 是包含边界值的

标签:not   ace   tle   select   条件   tween   bsp   知识   数据   

原文地址:http://www.cnblogs.com/cwc-1024/p/7196756.html

(3)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!