Dev.to
7/3/2026

5 SQL Interview Questions That Trip Up Beginners
Short summary
Five SQL gotchas that surprise beginners: WHERE runs before GROUP BY so aggregates don't exist yet—use HAVING instead; a table has one primary key, which can be composite; INNER JOIN with zero matches returns nothing (use OUTER JOIN to preserve unmatched rows); NULL isn't comparable with = or <>, use IS NULL instead; DELETE removes specific rows and can roll back, but TRUNCATE removes all rows, resets identity, and is faster but can't typically roll back.
- •WHERE filters before GROUP BY executes; use HAVING for aggregate conditions like COUNT() > 5
- •Primary keys are singular per table but can be composite (multiple columns)
- •INNER JOIN returns zero rows if unmatched; use LEFT/RIGHT/FULL OUTER to preserve unmatched data
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



