茫茫網海中的冷日 - 對這文章發表回應
茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1672022 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_0167.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

對這文章發表回應

發表限制: 非會員 可以發表

發表者: 冷日 發表時間: 2019/1/24 14:49:21

Oracle / PLSQL: BETWEEN Condition

This Oracle tutorial explains how to use the Oracle BETWEEN condition with syntax and examples.

Description

The Oracle BETWEEN condition is used to retrieve values within a range in a SELECT, INSERT, UPDATE, or DELETE statement.

Syntax

The syntax for the BETWEEN condition in Oracle/PLSQL is:

expression BETWEEN value1 AND value2;

Parameters or Arguments

expression
A column or calculation.
value1 and value2
Two values that create an inclusive range that expression is compared to.

Note


  • The Oracle BETWEEN condition will return the records where expression is within the range of value1 and value2 (inclusive).

Example - With Numeric

Let's look at some Oracle BETWEEN condition examples using numeric values. The following numeric example uses the BETWEEN condition to retrieve values within a numeric range.

For example:


SELECT *
FROM customers
WHERE customer_id BETWEEN 4000 AND 4999;

This Oracle BETWEEN example would return all rows from the customers table where the customer_id is between 4000 and 4999 (inclusive). It is equivalent to the following SELECT statement:


SELECT *
FROM customers
WHERE customer_id >= 4000
AND customer_id <= 4999;

Example - With Date

Next, let's look at how you would use the Oracle BETWEEN condition with Dates. The following date example uses the BETWEEN condition to retrieve values within a date range.

For example:


SELECT *
FROM order_details
WHERE order_date BETWEEN TO_DATE ('2014/02/01', 'yyyy/mm/dd')
AND TO_DATE ('2014/02/28', 'yyyy/mm/dd');

This Oracle BETWEEN condition example would return all records from the order_details table where the order_date is between Feb 1, 2014 and Feb 28, 2014 (inclusive). It would be equivalent to the following SELECT statement:


SELECT *
FROM order_details
WHERE order_date >= TO_DATE('2014/02/01', 'yyyy/mm/dd')
AND order_date <= TO_DATE('2014/02/28','yyyy/mm/dd');

Example - Using NOT Operator

The Oracle BETWEEN condition can also be combined with the Oracle NOT operator. Here is an example of how you would combine the BETWEEN condition with the NOT Operator.

For example:


SELECT *
FROM customers
WHERE customer_id NOT BETWEEN 3000 AND 3500;

This Oracle BETWEEN example would return all rows from the customers table where the customer_id was NOT between 3000 and 3500, inclusive. It would be equivalent to the following SELECT statement:


SELECT *
FROM customers
WHERE customer_id < 3000
OR customer_id > 3500;


原文出處:Oracle / PLSQL: BETWEEN Condition
內容圖示
url email imgsrc image code quote
樣本
bold italic underline linethrough   












 [詳情...]
validation picture

注意事項:
預覽不需輸入認證碼,僅真正發送文章時才會檢查驗證碼。
認證碼有效期10分鐘,若輸入資料超過10分鐘,請您備份內容後,重新整理本頁並貼回您的內容,再輸入驗證碼送出。

選項

Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|