在SQL中,BETWEEN操作符用于選擇在指定范圍內的值。以下是BETWEEN實際應用案例:
SELECT *
FROM orders
WHERE order_date BETWEEN '2021-01-01' AND '2021-12-31';
SELECT *
FROM products
WHERE price BETWEEN 50 AND 100;
SELECT *
FROM customers
WHERE age BETWEEN 30 AND 50;
SELECT *
FROM inventory
WHERE quantity BETWEEN 100 AND 500;
SELECT *
FROM movies
WHERE rating BETWEEN 7.0 AND 9.0;
通過以上案例可以看出,BETWEEN操作符可以方便地篩選出符合特定范圍條件的數據,從而更加靈活地進行數據查詢和分析。