Previous | Home | Next |
Using Logical Operator
Multiple search condition done by using logical operator. They are:
- OR: Any of the specified search condition is true.
- AND: When all specified search conditions are true.
- NOT: Neutralizes the expression that follow it.
SELECT column_list FROM table_name WHERE condition_expression OR condition_expression
Return all rows specific to the conditions, even if any one of the condition is true.
SELECT column_list FROM table_name WHERE condition_expression AND condition_expression
Return all rows specific to the conditions, when both conditions are true.
SELECT column_list FROM table_name WHERE condition_expression {OR/AND} NOT condition_expression
Return all rows specific to the conditions, except the rows that match the condition specified after the NOT operatoor.
Using List Operator
SQl provides IN and NOT IN operators. IN operator that allowed the selection of values that match any one of the values in a list. NOT IN operator restrict the selection of values that match any one of the values in a list.
SELECT column_list FROM table_name WHERE condition list_operator('value_list')
- list_operator is any valid list operator.
- value_list is the list of values to be included or excluded in the condition
Example:
SELECT * FROM publishers WHERE state IN ('MA','DC') SELECT * FROM publishers WHERE state NOT IN ('MA','DC')
Previous | Home | Next |