MySQL中BETWEEN子句的用法案例詳細(xì)說明
發(fā)表時(shí)間:2023-08-24 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]這篇文章主要介紹了MySQL中BETWEEN子句的用法詳解,是MySQL入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下可以使用IN子句來代替相結(jié)合的“大于等于和小于等于”的條件。要了解BETWEEN 子句考慮的EMPLOYEE_TBL表有以下記錄:mysql> SELECT * FROM emp...
這篇文章主要介紹了
MySQL中BETWEEN子句的用法詳解,是
MySQL入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下
可以使用IN子句來代替相結(jié)合的“大于等于和小于等于”的條件。
要了解BETWEEN 子句考慮的EMPLOYEE_TBL表有以下記錄:
mysql> SELECT * FROM employee_tbl;
+------+------+------------+--------------------+
id name work_date daily_typing_pages
+------+------+------------+--------------------+
1 John 2007-01-24 250
2 Ram 2007-05-27 220
3 Jack 2007-05-06 170
3 Jack 2007-04-06 100
4 Jill 2007-04-06 220
5 Zara 2007-06-06 300
5 Zara 2007-02-06 350
+------+------+------------+--------------------+
7 rows in set (0.00 sec)
現(xiàn)在,假設(shè)根據(jù)上表想獲取記錄條件daily_typing_pages超過170,等于和小于300。這可以使用如下條件>=和<=
mysql>SELECT * FROM employee_tbl
->WHERE daily_typing_pages >= 170 AND
->daily_typing_pages <= 300;
+------+------+------------+--------------------+
id name work_date daily_typing_pages
+------+------+------------+--------------------+
1 John 2007-01-24 250
2 Ram 2007-05-27 220
3 Jack 2007-05-06 170
4 Jill 2007-04-06 220
5 Zara 2007-06-06 300
+------+------+------------+--------------------+
5 rows in set (0.03 sec)
同樣可以實(shí)現(xiàn)使用BETWEEN子句如下:
mysql> SELECT * FROM employee_tbl
-> WHERE daily_typing_pages BETWEEN 170 AND 300;
+------+------+------------+--------------------+
id name work_date daily_typing_pages
+------+------+------------+--------------------+
1 John 2007-01-24 250
2 Ram 2007-05-27 220
3 Jack 2007-05-06 170
4 Jill 2007-04-06 220
5 Zara 2007-06-06 300
+------+------+------------+--------------------+
5 rows in set (0.03 sec)
以上就是MySQL中BETWEEN子句的用法實(shí)例詳解的詳細(xì)內(nèi)容,更多請關(guān)注php中文網(wǎng)其它相關(guān)文章!
學(xué)習(xí)教程快速掌握從入門到精通的SQL知識(shí)。