10. MySQL Part 1: Install, Create, Insert and SELECT
10.4 Inserting Data
INSERT INTO students (name, email, city, age, fees_paid, joined_on) VALUES
('Ravindra Bagale', 'ravindra@example.com', 'Pune', NULL, 15000, '2026-01-05'),
('Shraddha Bagale', 'shraddha@example.com', 'Pune', 29, 15000, '2026-01-05'),
('Ruhi Bagale', 'ruhi@example.com', 'Nashik', 21, 12000, '2026-02-10'),
('Shahrukh', 'shahrukh@example.com', 'Nagpur', 24, 8000, '2026-02-15'),
('Amir', 'amir@example.com', 'Kolhapur', 26, 15000, '2026-03-01'),
('Salman', 'salman@example.com', 'Solapur', 23, 0, '2026-03-03'),
('Zoya', 'zoya@example.com', 'Sambhaji Nagar', 22, 10000, '2026-03-20'),
('Ravina', 'ravina@example.com', 'Nagpur', 25, 12000, '2026-04-02'),
('Raja', NULL, 'Nashik', 20, 5000, '2026-04-11'),
('Rani', 'rani@example.com', 'Pune', 27, 15000, '2026-04-18');
INSERT INTO courses (course_name, duration_wk) VALUES
('Networking', 4), ('Linux', 6), ('AWS', 8), ('Ethical Hacking', 10), ('SOC Analyst', 6), ('Cloud Security', 6);
INSERT INTO enrollments (student_id, course_id, score) VALUES
(1,1,92),(1,4,88),(2,2,79),(3,1,65),(3,2,71),(4,4,58),(5,3,84),
(6,1,45),(7,5,90),(8,4,76),(8,5,81),(10,3,67);
SELECT COUNT(*) FROM students; -- 10
Student 9 (Raja) is deliberately in no course, course 2 (Linux) has two students and course 6 (Cloud Security) has none – we will need these for JOINs. Ravindra's age is left NULL on purpose for the NULL examples.
Why this matters for security
Every INSERT built from user input must use prepared statements (section 9.7). A value like '), ('hacker','x inside a string-concatenated INSERT can add extra rows or break the query – that is SQL injection in an INSERT.
Ravindra Bagale's Tip
Column list shivay INSERT INTO students VALUES (...) lihinare khup students aahet – nantar column vadhla ki query tutate. Nehmi column naave lihaa. Aani text single quotes 'Pune' madhe, numbers quotes shivay.
Practice task
Insert the sample data exactly as shown, then add yourself as a new student and one new course of your choice.