SQL Tutorial: Operators

Two types of operators
1.    Comparison Operators
2.    Logical Operators

Comparison Operators:

Equal to
Greater Than
Less Than
Greater than or equal to
Less than or equal to
Not Equal to
<> OR! =
between two Values, between an inclusive Range
Search for a character pattern, match a character pattern
If you know the exact value you want to return for at least one of the columns, Match any of a List of Values
Is a null value, column value does not exists

Important Notes:
1.      Comparison operators are used in WHERE clause or HAVING clause
  They compare one expression to another
  BETWEEN operator is always used with AND

    a. BETWEEN operator can be replaced by > or < operators  and  the result will be same
    b. BETWEEN operator is used with numeric data type

2.  IN can be replaced by = but the benefit of using IN is you can get multiple data of multiple values that is a list of values in one clause

a. IN operator can be used with any data type

3. LIKE operator is used to search for a character pattern when you do not the exact value you need to search for

a. The character matching search operation is referred as WILD CARD SEARCH
b. Two symbols % and _ are used to construct the search string
c.  % denotes zero or more characters for example S% means search the data for the character entry either S or any character starting from S alphabet.
d.  _  denotes any single character for example _S means search for the data whose second alphabet is S like ASAP

Logical Operators:
Combine the result of two component conditions to produce a Result
Invert the result
  1. AND
  2. OR
  3. NOT       

AND: Both conditions should be TRUE
OR: Either condition will be True
NOT: If the condition is FALSE then it will return TRUE


Torkona said...
This comment has been removed by a blog administrator.
messagepk said...

Display the full name of all employees with either an "E" or "S" in their last name.

Post a Comment