14-MySQL-Ubuntu-数据表的查询-范围查询(三)

范围查询

1,不连续查询-in, not in

查询年龄是12,18,34的学生姓名和年龄信息

select name,age from students where age in (12,18,34);

查询年龄不是12,18,34的学生姓名和年龄信息

select name,age from students where age not in (12,18,34);

2, 连续查询-between and,not between and

查询年龄在12到34之间的学生姓名和年龄信息(包括12和34);

select name,age from students where age between 12 and 34;

查询年龄不在12到34之间的学生姓名和年龄信息(不包括12和34);

select name,age from students where age not between 12 and 34;

原文地址:https://www.cnblogs.com/summer1019/p/11033027.html