Experiment No: 4
Title : Implementation of different types of operators in SQL.
• Arithmetic Operator
• Logical Operator
• Comparison Operator
• Special Operator
• Set Operator
Objective:
• To learn different types of operator.
Theory:
1) ARIHMETIC OPERATORS:
Addition (+) Adds values on either side of the operator
Subtraction (-) Subtracts right hand operand from left
Multiplication (*) Multiplies values on
either side of the operator
Division (/) Divide Left hand operand by right hand operand
power (^) Power- raise to power of
Modulus (%) Divides left hand operand by right hand operand and returns remainder
2) LOGICAL OPERATORS:
AND The AND operator allows the existence of multiple conditions in an SQL statement's
WHERE clause.
OR The OR operator is used to combine multiple conditions in an SQL statement's WHERE
clause
NOT The NOT operator reverses the meaning of the logical operator with which it is used.
3) COMPARISION OPERATORS:
(=) Checks if the values of two operands are equal or not, if yes then condition becomes true.
(!=) Checks if the values of two operands are equal or not, if values are not equal
then condition becomes true.
(< >) Checks if the values of two operands are equal or not, if values are not equal then condition
becomes true
(>) Checks if the value of left operand is less than the value of right operand, if yes
then condition becomes true.
(<) Checks if the value of left operand is less than the value of right operand, if yes then condition
becomes true
(>=) Checks if the value of left operand is greater than or equal to the value of right operand,
if yes then condition becomes true.
(<=) Checks if the value of left operand is less than or equal to the value of right operand, if yes then
condition becomes true.
4) SPECIAL OPERATOR:
BETWEEN The BETWEEN operator is used to search for values that are within a set of
values, given the minimum value and the maximum value.
IS NULL The NULL operator is used to compare a value with a NULL attribute value.
ALL The ALL operator is used to compare a value to all values in another value set
LIKE The LIKE operator is used to compare a value to similar values using wildcard
operators.It allows to use percent sign(%) and underscore ( _ ) to match a given string
pattern.
IN
The IN operator is used to compare a value to a list of literal values that have
been specified.
EXIST The EXISTS operator is used to search for the presence of a row in a specified table
that meets certain criteria.
5) SET OPERATORS:
Union Returns all distinct rows selected by both the queries
Union all Returns all rows selected by either query including the duplicates.
Minus Returns rows selected that are common to both queries.
Intersect Returns all distinct rows selected by the first query and are not by the second
LAB PRACTICE ASSIGNMENT:
• Display all the dept numbers available with the dept and emp tables avoiding
duplicates.
• Display all the dept numbers available with the dept and emp tables.
• Display all the dept numbers available in emp and not in dept tables and vice versa.
************************************