DATABASE & SQL/PLSQL

adplus-dvertising
Displaying Rows Using Logical & List Operators
Previous Home Next

Using Logical Operator

Multiple search condition done by using logical operator. They are:

  1. OR: Any of the specified search condition is true.
  2. 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.

  3. AND: When all specified search conditions are true.
  4. SELECT column_list
    FROM table_name
    WHERE  condition_expression AND condition_expression
    

    Return all rows specific to the conditions, when both conditions are true.

  5. NOT: Neutralizes the expression that follow it.
  6. 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') 
  1. list_operator is any valid list operator.
  2. 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