本篇介紹WHERE子句里面一個關鍵的語法知識點:Between語法
Between語法的作用
Between語法的使用范圍
Between語法的操作實例
-
Between語法的作用:
用於選取介於兩個值之間的數據范圍內的值
-
Between語句的使用范圍:
首先要定義這里的使用范圍指的是什么:
(1)使用場景
(2)使用的數據類型
(1)使用場景根據題目要求
(2)使用的數據類型:
1、數值
2、文本
3、日期
那么對應的Between語法是:
1、select * from table_name where column_name between value1 and value2;
2、select * from table_name where column_name between "text1"(例如:char類型的文字) and "text2";
3、select * from table_name where column_name between "dateytpe1" and "datetype2";
以上三種就是Betwee語句可以使用的數據類型。
擴展補充:Between in 語句:
從本質上來說,between in語句只是為了方便擴充的條件,不必要一個一個去打出來而已。
語法:
select * from table_name where ("text1" between "text2") and column_name in (constraint1、constraint2......);