Learner can write a basic SELECT … FROM … WHERE … ORDER BY query to verify data in a database.
Why testers query the database
Looking behind the curtain: SQL for testers
The UI only shows you what the application decides to display. A tester who can query the database directly sees what was actually stored — uncovering bugs that the front-end might hide or format away. For example, a registration form might show "Account created!", but the database could have saved the email in lowercase when uppercase was required, or stored NULL instead of the submitted value.
The most common tool for this is SQL (Structured Query Language). Even a basic read-only SELECT query lets you answer questions like: "Was the order really saved?" or "Was the discount applied correctly in the orders table?"
The core structure of a read query is:
SELECT column1, column2 FROM table_name WHERE condition ORDER BY column ASC;
Let's use a toy table called "orders" with columns: id, user_id, amount, status. A query like SELECT id, amount, status FROM orders WHERE status = 'pending' ORDER BY amount DESC; returns all pending orders sorted from highest to lowest amount. You can verify this against what the UI claims to show — if the numbers differ, you have found a bug to report.
Lesson notes
Looking behind the curtain: SQL for testers
The UI only shows you what the application decides to display. A tester who can query the database directly sees what was actually stored — uncovering bugs that the front-end might hide or format away. For example, a registration form might show "Account created!", but the database could have saved the email in lowercase when uppercase was required, or stored NULL instead of the submitted value.
The most common tool for this is SQL (Structured Query Language). Even a basic read-only SELECT query lets you answer questions like: "Was the order really saved?" or "Was the discount applied correctly in the orders table?"
The core structure of a read query is:
SELECT column1, column2 FROM table_name WHERE condition ORDER BY column ASC;
Let's use a toy table called "orders" with columns: id, user_id, amount, status. A query like SELECT id, amount, status FROM orders WHERE status = 'pending' ORDER BY amount DESC; returns all pending orders sorted from highest to lowest amount. You can verify this against what the UI claims to show — if the numbers differ, you have found a bug to report.