Complete SQL Learning Order
Practical SQL roadmap for MySQL / MySQL Workbench
1. Database Basics
CREATE DATABASE college;
USE college;
Learn how to create a database and select the database you want to work with.
2. Tables
CREATE TABLE student (
id INT,
name VARCHAR(50),
age INT
);
3. Insert Data
INSERT INTO student VALUES (1, 'Aman', 20);
Practice inserting one row and multiple rows.
4. SELECT
SELECT * FROM student;
SELECT name, age FROM student;
5. WHERE
SELECT * FROM student WHERE age > 18;
Filtering records according to a condition.
6. AND / OR / NOT
WHERE age > 18 AND name = 'Aman';
WHERE age = 18 OR age = 20;
WHERE NOT age = 18;
7. ORDER BY
SELECT * FROM student ORDER BY age ASC;
SELECT * FROM student ORDER BY age DESC;
8. DISTINCT
SELECT DISTINCT age FROM student;
Duplicate values ko remove karke unique values dikhata hai.
9. UPDATE
UPDATE student SET age = 21 WHERE id = 1;
10. DELETE
DELETE FROM student WHERE id = 1;
11. LIKE
SELECT * FROM student WHERE name LIKE 'A%';
SELECT * FROM student WHERE name LIKE '%an%';
% = any number of characters, _ = one character.
12. IN / BETWEEN
WHERE age IN (18, 20, 22);
WHERE age BETWEEN 18 AND 25;
13. Aggregate Functions
COUNT()
SUM()
AVG()
MIN()
MAX()
Example: SELECT COUNT(*) FROM student;
14. GROUP BY
SELECT age, COUNT(*)
FROM student
GROUP BY age;
15. HAVING
SELECT age, COUNT(*)
FROM student
GROUP BY age
HAVING COUNT(*) > 1;
GROUP BY ke baad groups ko filter karne ke liye HAVING use hota hai.
16. JOINS — Very Important
INNER JOIN → matching rows from both tables
LEFT JOIN → left table ki all rows + matching right rows
RIGHT JOIN → right table ki all rows + matching left rows
SELECT [Link], c.course_name
FROM student s
INNER JOIN course c
ON s.course_id = [Link];
17. Subqueries
SELECT name FROM student
WHERE age > (SELECT AVG(age) FROM student);
Ek query ke andar doosri query.
18. Constraints / Keys
PRIMARY KEY — unique row identification
FOREIGN KEY — tables ke beech relationship
NOT NULL — value required
UNIQUE — duplicate values prevent
DEFAULT — default value
Final Learning Order
CREATE DATABASE → USE → CREATE TABLE → INSERT → SELECT → WHERE → AND/OR/NOT →
ORDER BY → DISTINCT → UPDATE → DELETE → LIKE → IN/BETWEEN →
COUNT/SUM/AVG/MIN/MAX → GROUP BY → HAVING → JOINS → SUBQUERIES →
CONSTRAINTS/KEYS
Practice Rule
Har topic ke baad MySQL Workbench me khud 5–10 queries likh. Sirf video dekhkar next topic par mat jao.
SQL ka syntax practice se naturally yaad hota hai.