SQL Intermediate Interview Preparation

 Level            Type

1. Difference between INNER JOIN and LEFT JOIN?
➤ INNER JOIN returns matching rows, LEFT JOIN returns all rows from the left table.

2. What is a stored procedure?
➤ A saved collection of SQL statements that can be executed repeatedly.

3. What is a trigger?
➤ A trigger automatically performs actions in response to events on a table.

4. What is an alias in SQL?
➤ Temporary name for a table or column.

5. What is UNION and UNION ALL?
➤ UNION removes duplicates, UNION ALL includes all records.

6. How to prevent SQL injection?
➤ Use prepared statements and parameterized queries.

7. What is ACID property?
➤ Atomicity, Consistency, Isolation, Durability — ensures safe database transactions.

8. What is a transaction?
➤ A sequence of operations performed as a single logical unit of work.

9. How to update data in a table?
➤ Using UPDATE statement.

10. What is a composite key?
➤ A key made of two or more columns.

11. What is self join?
➤ Joining a table with itself.

12. How to find duplicate records in a table?
➤ Using GROUP BY and HAVING COUNT(*) > 1.

13. How to get the second highest salary?
➤ Using ORDER BY and LIMIT.

14. What is a temporary table?
➤ A table that exists temporarily during a session.

15. How do you backup a database?
➤ Using BACKUP command (SQL Server) or mysqldump (MySQL).

16. How do you restore a database?
➤ Using RESTORE command or import tools.

17. What is CASE WHEN in SQL?
➤ It's like an IF-ELSE logic in SQL.

18. What is COALESCE() function?
➤ Returns the first non-NULL value from the list.

19. What are aggregate functions?
➤ Functions like SUM(), AVG(), MAX(), MIN(), COUNT().

20. What is a correlated subquery?
➤ A subquery that depends on the outer query.

Comments

Popular posts from this blog

PHP INTERVIEW QUESTIONS

PHP Intermediate Questions Interview Preparation

PHP Interview Questions (Beginner Level) – Short Answers