recipes
All of these ran None were copied from a blog post
Rows above a threshold
SELECT host, port
FROM targets
WHERE port > ?
ORDER BY port DESC;
Count by category
SELECT severity, COUNT(*) AS n
FROM targets
GROUP BY severity;
Join with a filter
SELECT t.host, f.name
FROM targets t
INNER JOIN findings f ON f.target_id = t.id
WHERE t.severity = ?;
Safe read
const row = db.prepare("SELECT host FROM targets WHERE id = ?").get(id);
Undo a mistake
BEGIN;
DELETE FROM findings WHERE target_id = ?;
DELETE FROM targets WHERE id = ?;
ROLLBACK;
Swap ROLLBACK for COMMIT only after checking the row counts
End
The documentation gave me the boundaries The database gave the last word
Posted