Online admissions open for the SEO, PHP web development and networking & cybersecurity courses. Enquire for the next batch.

SQL Quiz: 12 MySQL Questions

Quiz · 12 questions Updated By the SkillNewton team

This free SQL quiz checks the database skills every web developer needs: writing SELECT queries with WHERE and ORDER BY, join types, GROUP BY and HAVING, NULL handling, indexes, primary and foreign keys, normalisation, transactions and ACID, DELETE versus TRUNCATE and preventing SQL injection. Questions use MySQL behaviour. Answer all 12 questions, check your score, then read the explanations and revisit the MySQL guide for anything you got wrong.

Choose one answer for each question, then check your score. Your answers stay in this browser and are not saved.

1. Which query returns students from Delhi, sorted by name?
2. You need every customer, including those who have never placed an order. Which join do you use (customers on the left)?
3. You want cities that have more than 10 students. Where does the condition COUNT(*) > 10 go?
4. Which condition finds rows where phone has no value (NULL)?
5. A table has 5 rows, and 2 of them have NULL in email. What does SELECT COUNT(email) return?
6. What is the main trade-off of adding an index to a column?
7. Which statement about a primary key is true?
8. What does a foreign key on orders.customer_id referencing customers.id do?
9. A students table stores several numbers in one column, such as "98xxxxxxx1, 99xxxxxxx2". Which normal form does this break?
10. A transfer debits one account and credits another inside a transaction. Which ACID property ensures both happen or neither does?
11. Which statement about TRUNCATE TABLE in MySQL is true?
12. What is the most reliable way to prevent SQL injection?

Frequently asked questions

Is this quiz only for MySQL?

Most questions apply to any SQL database. Where behaviour differs, such as TRUNCATE and AUTO_INCREMENT, the quiz follows MySQL with the InnoDB engine.

Where can I practise these queries?

Install MySQL or MariaDB locally (for example through XAMPP), create a small students or orders table and run the queries yourself.

Why is SQL injection in a SQL quiz?

Because it comes from how application code builds queries. Using prepared statements is part of writing SQL safely.

Want to Learn This Properly?

The PHP Web Development: Foundation & Practical Implementation (Online) turns resources like this into practised skills, with projects on real websites.

WhatsApp Call Us Now

Free counselling

Send an Enquiry

Tell us which course you are interested in. We reply by email or phone with the next batch and how to enrol.

We reply by email or phone within working hours. No spam.