They do completely different things, so I'm not sure why you grouped them into one question.
ORDER BY is pretty straightforward: it arranges the results to be in alphabetical or numerical order (or the reverse, if you use ORDER BY column_name DESC). Without it, you get the results in whatever order the database feels like giving them to you, which can and probably will change as new rows are added.
The HAVING clause is a little trickier. It's used to restrict the selection based on grouped results (in other Words, you can think of it as a variation on the WHERE clause). It can be used to e.g. find duplicates:
SELECT Should_Be_Unique_ID
FROM MyTable
GROUP BY Should_Be_Unique_ID
HAVING COUNT(*) > 1;
Copyright © 2026 eLLeNow.com All Rights Reserved.