WHERE Conditions
The WHERE conditions filter the output of the FROM clause and restrict the returned rows in the result set. The conditions can refer to the data within the tables, expressions, built-in SQL Server scalar functions, other queries, or user-defined functions. The WHERE conditions can also use several possible comparison operators and wildcards, as listed in Table 6.1. In addition, you can combine multiple WHERE conditions using Boolean AND, OR, and NOT operators.
Description | Operator | Example |
Equals | = | Quantity = 12 |
Greater than | > | Quantity > 12 |
Greater than or equal to | >= | Quantity >= 12 |
Less than | < | Quantity < 12 |
Less than or equal to | <= | Quantity<= 12 |
Not equal to | <> , != | Quantity <> 12 , Quantity != 12 |
Not less than | !< | Quantity !< 12 |
Not greater than | !> | Quantity !> 12 |
In addition to the standard comparison operators, which are no doubt familiar, SQL provides four special comparison operators: BETWEEN, IN, LIKE, and IS. The first three are explained in this section. Testing ...
Get Microsoft SQL Server 2012 Bible now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.