Answer» Clauses are in-built functions available in SQL and are used for filtering and analysing data quickly allowing the user to efficiently extract the required information from the database. The below table lists some of the important SQL clauses and their description with examples:
| Name | Description | Example |
|---|
| WHERE | Used to select data from the database based on some conditions. | SELECT * from Employee WHERE age >= 18; |
|---|
| AND | Used to combine 2 or more conditions and returns true if all the conditions are True. | SELECT * from Employee WHERE age >= 18 AND salary >= 45000 ; |
|---|
| OR | Similar to AND but returns true if any of the conditions are True. | Select * from Employee where salary >= 45000 OR age >= 18 |
|---|
| LIKE | Used to search for a specified pattern in a column. | SELECT * FROM Students WHERE Name LIKE ‘a%’; |
|---|
| LIMIT | Puts a restriction on how many rows are returned from a query. | SELECT * FROM table1 LIMIT 3; |
|---|
| ORDER BY | Used to sort given data in Ascending or Descending order. | SELECT * FROM student ORDER BY age ASC |
|---|
| GROUP BY | Groups rows that have the same values into summary rows. | SELECT COUNT(StudentID), State FROM Students GROUP BY State; |
|---|
| HAVING | It performs the same as the WHERE clause but can also be used with aggregate functions. | SELECT COUNT(ID), AGE FROM Students GROUP BY AGE HAVING COUNT(ID) > 5; |
|---|
|