Databases · Junior · Question 48 of 75

What is SQL injection?

const sql = "SELECT * FROM users WHERE name = '" + name + "'";

Explanation

Never build SQL from strings. Use parameters (WHERE name = $1), which drivers send separately from the query text.

Further reading

Problem with a question

Databases · Junior · question 48

Test yourself

Take the Databases · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz