What is difference between WHERE and HAVING clause in SQL is one of the most popular question asked on SQL and database interviews, especially for beginners.
WHERE
- We can use WHERE clause with SELECT, INSERT, UPDATE and DELETE clause. For Example it works fine for "Update Mas_Employee Set Salary = 1500 WHERE Id =1".
- WHERE clause is used for filtering rows and it applies on each and every row.
- WHERE clause is used before GROUP BY clause.
- We can't use aggregate functions in the where clause unless it is in a sub query contained in a HAVING clause.
HAVING
- HAVING clause can only be used with SELECT query. Means if you want perform INSERT, UPDATE and DELETE clause it will retuns an error. For Example "Update Mas_Employee Set Salary = 1500 Having Id =1" Query will be generated error like "Incorrect syntax near the keyword 'HAVING'. ".
- HAVING clause is used to filter groups in SQL.
- HAVING clause is used after GROUP BY clause.
- We can use aggregate function in HAVING clause.
Please provide your valuable suggestions and feedback if you found this article helpful.

Ravi vishwakarmaPosted Nov 11, 2018, 7:10 AM
How we can insert data with where clause?
Masudur RahmanPosted Sep 24, 2018, 10:27 PM
Very helpful.thanks a lot.
Wasim SolankiPosted Aug 6, 2018, 3:43 PM
Thanks for the useful information..
Raj SharmaPosted Jun 5, 2018, 6:36 AM
Great Explanation..!
Satya Naryan RoyPosted May 7, 2018, 6:47 AM
Thanks for valuable information
Siva ChanduPosted Jan 12, 2018, 11:25 AM
Thanks for information
Santhakumar MunuswamyPosted Jun 13, 2015, 10:39 AM
Thanks for sharing