SQL Injection happens when unsanitized user input flows directly into a database query, letting an attacker alter the query's structure.
A simple example
Suppose a query is built as SELECT * FROM users WHERE username = '{input}'. If a user submits ' OR '1'='1, the condition always evaluates true and the entire table is returned.
Why is it still common?
Despite being known since the 1990s, it remains on the OWASP Top 10 — mostly due to legacy code or ORM misuse that bypasses parameterization.
The real fix
Always use parameterized queries or an ORM; never build SQL strings via concatenation or f-strings. Also apply least privilege to your application's database user.
Never concatenate user input directly into an SQL query.