SQL Basics
SQL lets you ask questions from structured data. Start by learning how to read data clearly before trying to design complex queries.
SELECT
Use SELECT to choose columns and FROM to choose the table.
SELECT id, name, email
FROM users;
WHERE
Use WHERE to filter rows. In testing, always make filters explicit so the query is reproducible.
SELECT order_id, status, total_amount
FROM orders
WHERE status = 'FAILED';
ORDER BY and LIMIT
Sort results to make debugging predictable. Use LIMIT when inspecting large tables.
SELECT order_id, created_at, status
FROM orders
ORDER BY created_at DESC
LIMIT 20;
NULL
NULL means missing or unknown. Do not compare it with =. Use IS NULL or IS NOT NULL.
SELECT user_id, phone
FROM users
WHERE phone IS NULL;
QA habit: when validating a UI or API result, query using a stable identifier such as order id, user id, email, or request correlation id.