SQLIntermediate#security

What is SQL injection and how do you prevent it?

An attack where user input is concatenated into SQL and changes its meaning. Prevent it with parameterised queries or prepared statements, least-privilege database users and input validation — never string concatenation.

Example
-- vulnerable
"SELECT * FROM users WHERE email = '" + input + "'"
-- safe
PREPARE s FROM 'SELECT * FROM users WHERE email = ?';

Related Questions

1
SQLAdvanced#aggregates

What is GROUP BY with ROLLUP?

Open
2
SQLIntermediate#queries#performance

How do you paginate results efficiently?

Open
3
SQLBeginner#fundamentals

What are DDL, DML, DQL, DCL and TCL?

Open