Comparison Search Conditions
Microsoft® SQL Server™ 2000 uses these comparison operators.
Operator | Meaning |
---|---|
= | Equal to |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
< > | Not equal to (SQL-92 compatible) |
!> | Not greater than |
!< | Not less than |
!= | Not equal to |
Comparison operators are specified between two
SELECT ProductName
FROM Northwind.dbo.Products
WHERE UnitPrice > $50.00
When you compare character string data, the logical sequence of the characters is defined by the collation of the character data. The result of comparison operators such as < and > are controlled by the character sequence defined by the collation. The same SQL Collation might have different sorting behavior for Unicode and non-Unicode data. (For more information, see SQL Server Collation Fundamentals.)
Trailing blanks are ignored in comparisons in non-Unicode data; for example, these are equivalent:
WHERE au_lname = 'White'
WHERE au_lname = 'White '
WHERE au_lname = 'White' + SPACE(1)
The use of NOT negates an expression. For example, this query finds all products that have a unit price of $50 or more, which is logically the same as asking for all products that do not have a unit price of less than $50:
SELECT ProductID, ProductName, UnitPrice
FROM Northwind.dbo.Products
WHERE NOT UnitPrice < $50
ORDER BY ProductID