August 13th, 2008

Conditions and Comparisons

Posted by admin in C. SELECT Statement

There are five types of conditions in SQL:

Operators           Conditions       
=, <>, <, >, <=, >= Comparison
IS NULL             Null testing
BETWEEN             Range of values
IN                  In a list
LIKE                Pattern matching

IS NULL, BETWEEN, IN, and LIKE will be covered later.

There are six logical comparison operators or predicates in SQL:

Operator  Comparison                Expression       
=         Equal to                  MAX_THRUST = 500
<>        Not equal to              MAX_THRUST <> 500
<         Less than                 MAX_THRUST < 500
>         Greater than              MAX_THRUST > 500
<=        Less than or equal to     MAX_THRUST <= 500
>=        Greater than or equal to  MAX_THRUST >= 500

Notice that “=<” and “=>”are invalid. Only use “<=” and “>=”.

Combine and negate with:

AND   Both conditions are true
OR     Either condition is true
NOT   Reverse a condition

Comments are closed.

Sorry, the comment form is closed at this time.