TGTGInsighttelegram intelligenceLIVE / telegram public index
← Data Analytics
Data Analytics avatar

TGINSIGHT POST

Post #2461

@sqlspecialist

Data Analytics

Views8,660Post view count
PostedDec 1112/11/2025, 11:54 AM
Post content

Post content

✅Top SQL Interview Questions with Answers: Part-1🧠 1. What is SQL and why is it used? SQL (Structured Query Language) is used to manage and manipulate relational databases. It allows users to retrieve, insert, update, and delete data efficiently. 2. Difference between SQL and MySQL - SQL is a language used to interact with databases. - MySQL is a relational database management system (RDBMS) that uses SQL. Think of SQL as the language, and MySQL as the software that understands and processes it. 3. What are primary keys and foreign keys?🔑 - Primary Key uniquely identifies each row in a table. It must be unique and not null. - Foreign Key links one table to another. It references the primary key of another table to maintain referential integrity. 4. What is a unique constraint? It ensures that all values in a column (or combination of columns) are unique across the table. Unlike primary keys, columns with a unique constraint can accept one NULL. 5. Difference between WHERE and HAVING - WHERE filters rows before aggregation. - HAVING filters groups after aggregation. Example: Use WHERE for filtering raw data, HAVING for filtering GROUP BY results. 6. What are joins? Types of joins?🤝 Joins combine data from multiple tables based on related columns. Types: - INNER JOIN – Returns matching rows - LEFT JOIN – All rows from left table + matched rows from right - RIGHT JOIN – All rows from right table + matched from left - FULL JOIN – All rows from both tables - CROSS JOIN – Cartesian product 7. Difference between INNER JOIN and LEFT JOIN - INNER JOIN only returns rows with matching keys in both tables. - LEFT JOIN returns all rows from the left table, plus matching rows from the right table (NULLs if no match). 8. What is a subquery? A subquery is a query nested inside another SQL query. It can be used in SELECT, FROM, or WHERE clauses to fetch intermediate results. 9. What are CTEs (Common Table Expressions)? CTEs are temporary named result sets that make queries more readable and reusable. Syntax: WITH cte_name AS ( SELECT ... ) SELECT * FROM cte_name; 10. What is a view in SQL? A view is a virtual table based on a SQL query. It doesn't store data itself but provides a way to simplify complex queries, improve security, and reuse logic. Double Tap ❤️ For Part-2