SQL - Structured Query Language

Logical Operators

Logical operators are used to test for the truth of some condition that returns a Boolean data type with a value of TRUE, FALSE or UNKNOWN.

List of Logical Operators

Operator Description
ALL TRUE if all of a set of comparisons are TRUE.
AND TRUE if both Boolean expressions are TRUE.
ANY TRUE if any one of a set of comparisons are TRUE.
BETWEEN TRUE if the operand is within a range.
EXISTS TRUE if a subquery contains any rows.
IN TRUE if the operand is equal to one of a list of expressions.
LIKE TRUE if the operand matches a pattern.
NOT Reverses the value of any other Boolean operator.
OR TRUE if either Boolean expression is TRUE.
SOME TRUE if some of a set of comparisons are TRUE.

Boolean Constants

Databases and other programming environments provide operators you can use to perform data analysis. The operators used are called logical operators because they are used to perform comparisons that produce a result of true or false.

TRUE and FALSE Constants

In Boolean algebra, something is considered TRUE when it holds a value. The value is also considered like 1 or Yes. By contrast, if something doesn't hold a value, it is considered non-existent and non-worthy of consideration. Such a thing has a value of FALSE, 0 or No. To retrieve such a value, you can just find out if the value of a field is existent or not.

NULL Constant

While the True and False constants are used to find out whether a Boolean field has a positive or a negative value, the database provides another constant used to find out whether a field is empty. This can be done using the NULL constant.

When a field holds a value, the value would be considered using the comparison operators we will learn shortly. If the field is empty, it holds a value of NULL.

More Reference URL: http://technet.microsoft.com/en-us/library/ms189773.aspx

* * * * *

Email Your Comment To AUTHOR