SQL Fundamentals for Security Professionals
Every significant web application — banking portals, e-commerce platforms, healthcare systems, social networks — stores its data in a relational database and retrieves it using SQL. SQL injection attacks have been listed in the OWASP Top 10 for over two decades because they remain devastatingly effective. In 2008, a single SQL injection campaign against Heartland Payment Systems exposed more than 130 million credit card numbers. In 2012, attackers used SQL injection against LinkedIn and stole 117 million hashed passwords.
You cannot understand SQL injection without first understanding SQL. This lab gives you hands-on practice writing real queries so that when you encounter injection vulnerabilities — or audit code for them — you will recognize exactly what is happening.
The In-Browser SQL Workbench
The interactive panel alongside this lesson runs a complete SQL engine directly in your browser. It contains three tables representing a small e-commerce application:
- users — registered accounts with an id, email address, role (admin, user, or moderator), and creation date
- orders — purchase records with an id, the id of the user who placed the order, a total amount, a status (completed, pending, or cancelled), and a creation date
- products — items available for sale with an id, name, price, and category
These three tables are related: orders.user_id references users.id. This relationship is what you will exploit in Task 5 when you write a JOIN query.
What You Will Practice
Over five tasks you will write queries that progress from basic to intermediate:
- Retrieve all records from a table using
SELECT * - Filter records by a condition using
WHERE - Sort results using
ORDER BY - Count matching records using
COUNT(*) - Combine two tables using
JOIN
No prior database experience is required. Each task builds directly on the previous one. By the end of this lab you will have written the same class of query that attackers manipulate during SQL injection — and you will understand precisely why unparameterized queries are dangerous.
Type each query into the editor in the right panel and click Run Query to see the results.