开发者学堂课程【MySQL数据库入门学习:where 语句中 between 操作符使用】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/451/detail/5581
where 语句中 between 操作符使用
语法:
between在英语中的意思是在...之间,在sql语句中作用就是筛选在值1和值2之间的数据。
select *from 表名 where 列名 between 值1and 值2
select *from 表名 where 列名 not between 值1and 值2
演示:
Database changed
mysql>select *from book;
id title content pages
1 sun nice day 10
2 title nice day 9
3 nice tree bad day 20
5 color nice day 3
4 redcolorday nice day 15
筛选 id 在 1和3之间的数据
mysql>select *from book where id between 1 and3;
id title content pages
1 sun nice day 10
2 title nice day 9
3 nice tree bad day 20
筛选 id 不在 1和3之间的数据
mysql>select *from book where id not between1 and3:
id title content pages
5 color nice day 3
4 redcolorday nice day 15