Skip to content

A complete collection of the Top 100 MySQL & SQL Interview Questions with Answers, crafted from an interview perspective. Covers fundamentals to advanced topics including joins, indexing, subqueries, and optimization. Ideal for developers, students, and job seekers preparing for tech interviews.

Notifications You must be signed in to change notification settings

ChinmayKaitade/SQL-MySQL-Interview-Practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MySQL Logo

MySQL Practice Series 🔥🚀❤️‍🔥

Welcome to the MySQL Practice Repo! 🚀
This repository is perfect for practicing SQL queries including CRUD operations, Joins, Functions, Constraints, and Interview Questions preparation.


What's Inside?

  • 🔹 100 Most Asked SQL/MySQL Interview Questions
  • 🔹 Real-world Use Cases & Scenario-Based Queries
  • 🔹 Performance Tips & Optimization Techniques
  • 🔹 Window Functions, Joins, Indexing, JSON & More

📂 How to Use

  • Clone the repo
  • Read through the markdown or PDF format
  • Practice each question with a database like MySQL Workbench, phpMyAdmin, or DB Fiddle
  • Revise before your interview or assessment

✅ Types of SQL Commands:

👉 DDL (Data Definition Language): create, alter, rename, truncate & drop

👉 DQL (Data Query Language): select

👉 DML (Data Manipulation Language): insert, update & delete

👉 DCL (Data Control Language): grant & revoke permission to users

👉 TCL (Transaction Control Language): start transaction, commit, rollback

Keys🗝️

✔️ Primary Key: It is a column (or set of columns) in a table that uniquely identifies each row. (a unique id) There is only 1 PK & it should be NOT null.

✔️ Foreign Key: A foreign key is a column (or set of columns) in a table that refers to the primary key in another table. FKs can have duplicate & null values.

📌 Table of Contents


🔧 CRUD Operations

🟢 Create (INSERT)

INSERT INTO employees (id, name, age, department)
VALUES (1, 'Alice', 28, 'IT');

🔍 Read (SELECT)

SELECT * FROM employees;
SELECT name, department FROM employees WHERE age > 25;

📝 Update

UPDATE employees
SET department = 'HR'
WHERE id = 1;

❌ Delete

DELETE FROM employees
WHERE id = 1;

📋 Advanced Queries

  • 🔢 Aggregate Functions
SELECT COUNT(*) FROM employees;
SELECT AVG(age) FROM employees;
  • 🧩 GROUP BY
SELECT department, COUNT(*) FROM employees GROUP BY department;
  • 🚫 HAVING
SELECT department, COUNT(*) FROM employees
GROUP BY department
HAVING COUNT(*) > 2;

🔗 Joins

👥 INNER JOIN

SELECT e.name, d.name AS dept_name
FROM employees e
INNER JOIN departments d ON e.department_id = d.id;

🚀 LEFT JOIN

SELECT e.name, d.name
FROM employees e
LEFT JOIN departments d ON e.department_id = d.id;

🧠 Functions & Clauses

  • ⏱️ NOW() – Current timestamp
  • 🗓️ DATE() – Extract date
  • 🔠 UPPER(), LOWER() – Case conversion
  • 🔎 LIKE, IN, BETWEEN – Conditional filters
SELECT * FROM orders
WHERE order_date BETWEEN '2024-01-01' AND '2024-12-31';

SELECT * FROM employees
WHERE name LIKE 'A%';

📎 Constraints

  • 🔑 Primary Key
  • 🗝️ Foreign Key
  • 🔒 NOT NULL
  • 🛡️ UNIQUE
  • ✅ CHECK
CREATE TABLE students (
    id INT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    age INT CHECK (age >= 18)
);

📂 Sample Database

You can practice with:

  • employees 👨‍💼
  • departments 🏢
  • orders 🧾
  • products 🛒
  • students 🎓

Use dummy data or import from Mockaroo for realistic datasets.


📣 Contribution

Feel free to fork this repo, add new queries, or create issue threads if you find bugs or want improvements!


🌟 Don't forget to

  • ⭐ Star the repository
  • 🍴 Fork it
  • 📢 Share with friends & developers preparing for interviews
  • 🔁 Keep practicing daily!

📩 Lets Connect

Chinmay'sLinkedinHandle | Chinmay'sInstagramHandle | Chinmay'sXHandle


"Practice makes perfect — keep querying until it's second nature!" 💪

About

A complete collection of the Top 100 MySQL & SQL Interview Questions with Answers, crafted from an interview perspective. Covers fundamentals to advanced topics including joins, indexing, subqueries, and optimization. Ideal for developers, students, and job seekers preparing for tech interviews.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published