美文网首页
2019-11-29_between

2019-11-29_between

作者: l_link | 来源:发表于2019-12-02 15:39 被阅读0次

    between: 按规定返回所需记录的数目

    格式如下:

     列名     包含与 “A” and “B”

    select * from table where “列名” between “A” and “B”(包含A,B)

    列名     不包含与 “A” or “B”

    select * from table where “列名” not between “A” and  “B”(不包含A,B)

    例如:表如下

    (插入表的语句参照文章2019-11-22)

    1.需求:按age(年龄)排序,查询出前年龄介于12岁到13岁之间的学生

    select * from student WHERE age BETWEEN 12 and 13

    等价于    select * from student WHERE age >= 12 and  age <= 13

    结果如下:

    2.需求:按age(年龄)排序,查询出前年龄小于11或者大于12岁的学生

    select * from student WHERE age not BETWEEN 11 and 12

    等价于    select * from student WHERE age < 11 or  age > 12

    相关文章

      网友评论

          本文标题:2019-11-29_between

          本文链接:https://www.haomeiwen.com/subject/tacfgctx.html