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

适用对象: 是SQL Server 是Azure SQL 数据库 是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). 比较非空表达式时,如果左边操作数的值小于或等于右边的操作数,则结果为 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

BooleanBoolean

示例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)