WHERE Clause

Selecting Rows with Conditional Restrictions

The WHERE clause is used to add conditional restrictions to the SELECT statement that limit the rows returned by the query

SELECT   columnlist

 FROM   tablelist

 [WHERE   conditionlist ]

 [ORDER BY   columnlist [ASC | DESC] ];

Symbol

Meaning

=

Equal to

<

Less than

<=

Less than or equal to

>

Greater than

>=

Greater than or equal to

<> or !=

Not equal to

 

  • Using Comparison Operators on Character Attributes

    • Comparison operators may be used to place restrictions on character-based attributes

 

  • Using Comparison Operators on Dates

    • Date procedures are often more software-specific than other SQL procedures

 

  • Logical Operators: AND, OR, and NOT

    • SQL allows you to include multiple conditions in a query through the use of these logical operators

    • Boolean algebra is dedicated to the use of logical operators

 

Special Operators

  • BETWEEN – Used to check whether an attribute value is within a range

  • IN – Used to check whether an attribute value matches any value within a value list

  • LIKE – Used to check whether an attribute value matches a given string pattern

  • IS NULL – Used to check whether an attribute value is null

  • NOT – Used to negate a condition

 

Â