- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between Where and Having
Both Where and Having are the two keywords used in SQL query to filter and summarize the data that is retrieved from database based on given condition.
On the basis of features of both keywords we can distinguish between Where and Having as follows −
Sr. No. | Key | Where | Having |
---|---|---|---|
1 | Definition | WHERE clause in SQL query specifies search conditions for the rows returned by the it and limits rows to a specific row-set. In case if user wants to get the particular records based on some specific classification or condition then using ‘where’ clause is useful. | The WHERE clause is used to specify the required condition (on aggregate values) while selecting the rows of a table. |
2 | Execution | As per the order of execution of clauses, the WHERE clause is executed before the execution of the GROUPBY CLAUSE and, after the execution of the FROM clause. | On other hand HAVING clause is executed after groups are created. |
3 | GroupBy compatibility | WHERE clause can be used with GroupBy clause in a SQL query. | On other hand, Having clause does not have compatibility with GroupBy clause. |
4 | Row selection | WHERE clause select the rows before grouping of result. | On other hand Having clause selects the rows after grouping. |
5 | Aggregate Function | WHERE clause cannot contain the aggregate function. | On other hand HAVING clause can contain the aggregate function. |
Advertisements