HAVING clauses are used with some conditions to filter out undesired records from the result set. It helps us retrieving or modifying specific information of a table excluding any irrelevant data. For example, when you want to see the information about students in class 10th only then you don’t need the information about the students in other class. Retrieving information about all the students would obviously increase both the processing time and cost.
SELECT * FROM student WHERE class = 10;
WHERE vs HAVING
The difference between the
HAVING clause and the
WHERE clause is that the
WHERE clause is used to filter rows, while the
HAVING clause is used to filter groups of rows i.e it is meant to be used with
GROUP BY clause specially.
Operators are used inside the conditional statement. E.g in above example equal (=) is an operator. Operators are broadly divided into 4 categories.
- Arithmetic operators
- Comparison operators
- Logical operators
- Operators used to negate conditions