Parameterised queries
Database queries whose SQL structure is fixed in advance, with user data passed separately as parameters and read only as data; the primary defence against SQL injection.
A parameterised query, usually run as a prepared statement, sends the database the query’s structure with placeholders, and supplies the values separately. Because the structure of the command is fixed separately from the values, an input containing quote marks or SQL keywords is treated as a value to compare or store, not as part of the command. NIST SP 800-53 Rev. 5 explains the principle in SI-10(6): parameterised interfaces separate data from code, so injected data cannot change the meaning of the command being sent. OWASP’s SQL Injection Prevention Cheat Sheet lists them as its first defence option.
It is the primary defence against SQL injection, and it differs from input validation, which checks what the input looks like; input can pass validation and still be malicious, whereas a bound parameter is not parsed as part of the query. It has limits: parts of a query that cannot be parameters, such as table or column names, need an allowlist or a redesign, and a stored procedure that joins input into SQL is still injectable. Output encoding applies the same separation to web pages.
Exam relevance: a scenario asking for the most effective fix for SQL injection is likely to favour parameterised queries over filtering, escaping or a web application firewall alone. Candidates are expected to treat validation as a supporting layer.