SQL Tutorial: Operators
Operators:
Two types of operators
1. Comparison Operators
Comparison Operators:
Equal to | = |
Greater Than | > |
Less Than | < |
Greater than or equal to | >= |
Less than or equal to | <= |
Not Equal to | <> OR! = |
BETWEEN | between two Values, between an inclusive Range |
LIKE | Search for a character pattern, match a character pattern |
IN | 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 NULL | 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
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
- AND
- OR
- NOT
AND: Both conditions should be TRUE
OR: Either condition will be True
NOT: If the condition is FALSE then it will return TRUE
OR: Either condition will be True
NOT: If the condition is FALSE then it will return TRUE
This comment has been removed by a blog administrator.
ReplyDeleteDisplay the full name of all employees with either an "E" or "S" in their last name.
ReplyDelete