Q11. What is a SQL Query?
Answer:
A SQL query is a command written to interact with the database. It is used to retrieve, insert, update, or delete data.
Example: SELECT * FROM Employees;
Q12. What are DDL, DML, DCL, and TCL in SQL?
Answer:
Command Type | Full Form | Example Commands |
---|---|---|
DDL | Data Definition Language | CREATE, ALTER, DROP |
DML | Data Manipulation Language | SELECT, INSERT, UPDATE |
DCL | Data Control Language | GRANT, REVOKE |
TCL | Transaction Control Language | COMMIT, ROLLBACK, SAVEPOINT |
Q13. What is the SELECT statement used for?
Answer:SELECT
is used to retrieve data from a database.
Example: SELECT Name, Age FROM Students;
Q14. How do you retrieve all the records from a table?
Answer:
Use the SELECT *
statement.
Example: SELECT * FROM Customers;
Q15. What does the WHERE clause do in SQL?
Answer:
The WHERE
clause is used to filter records that meet specific conditions.
Example: SELECT * FROM Employees WHERE Age > 25;
Q16. What is the use of the ORDER BY clause?
Answer:ORDER BY
sorts the result set in ascending or descending order.
Example: SELECT * FROM Students ORDER BY Name ASC;
Q17. What is the purpose of the GROUP BY clause?
Answer:GROUP BY
is used to group rows that have the same values in specified columns.
Example: SELECT Department, COUNT(*) FROM Employees GROUP BY Department;
Q18. What is the HAVING clause in SQL?
Answer:HAVING
is used to filter groups based on conditions (used with GROUP BY).
Example:SELECT Department, COUNT(*) FROM Employees GROUP BY Department HAVING COUNT(*) > 5;
Q19. What is a JOIN in SQL?
Answer:JOIN
is used to combine rows from two or more tables based on a related column.
Q20. What are different types of JOINs in SQL?
Answer:
JOIN Type | Description |
---|---|
INNER JOIN | Returns matching records from both tables |
LEFT JOIN | All records from left table + matching from right |
RIGHT JOIN | All records from right table + matching from left |
FULL JOIN | All records when there is a match in one of the tables |
Example (INNER JOIN):
1 thought on “Top 50 Basic Level SQL Interview Questions – Beginners Guide”