<= (小於或等於) (Transact-SQL)<= (Less Than or Equal To) (Transact-SQL)

適用於: 是SQL Server 是Azure SQL Database 是Azure Synapse Analytics (SQL DW) 是平行處理資料倉儲 APPLIES TO: yesSQL Server yesAzure SQL Database yesAzure Synapse Analytics (SQL DW) yesParallel Data Warehouse

比較兩個運算式 (比較運算子)。Compares two expressions (a comparison operator). 當您在比較非 Null 運算式時,如果左運算元的值小於或等於右運算元,則結果為 TRUE,否則結果就是 FALSE。When you compare nonnull expressions, the result is TRUE if the left operand has a value lower than or equal to the right operand; otherwise, the result is FALSE.

與 = (等於) 比較運算子不同的是,兩個 NULL 值的 >= 比較結果不受 ANSI_NULLS 設定的影響。Unlike the = (equality) comparison operator, the result of the >= comparison of two NULL values does not depend on the ANSI_NULLS setting.

主題連結圖示 Transact-SQL 語法慣例Topic link icon Transact-SQL Syntax Conventions

語法Syntax

expression <= expression  

引數Arguments

expressionexpression
這是任何有效的運算式Is any valid expression. 這兩個運算式的類型,都必須是可以隱含轉換的資料類型。Both expressions must have implicitly convertible data types. 轉換會隨著資料類型優先順序的規則而不同。The conversion depends on the rules of data type precedence.

結果類型Result Types

布林Boolean

範例Examples

A.A. 在簡單查詢中使用 <=Using <= in a simple query

下列範例會傳回 HumanResources.Department 資料表中,DepartmentID 的值小於或等於 3 的所有資料列。The following example returns all rows in the HumanResources.Department table that have a value in DepartmentID that is less than or equal to the value 3.

-- Uses AdventureWorks  
  
SELECT DepartmentID, Name  
FROM HumanResources.Department  
WHERE DepartmentID <= 3  
ORDER BY DepartmentID;  
  

以下為結果集:Here is the result set.

DepartmentID Name  
------------ --------------------------------------------------  
1            Engineering  
2            Tool Design  
3            Sales  
  
(3 row(s) affected)  
  

另請參閱See Also

資料類型 (Transact-SQL) Data Types (Transact-SQL)
運算子 (Transact-SQL)Operators (Transact-SQL)