Bird
0
0

Given the query SELECT * FROM orders WHERE customer_id = ? and the parameter value 42, what will the query return if customer_id 42 exists?

medium📝 query result Q4 of 15
SQL - Security Basics
Given the query SELECT * FROM orders WHERE customer_id = ? and the parameter value 42, what will the query return if customer_id 42 exists?
AAn error because parameter is not named
BAll orders for all customers
CNo results because parameter binding is missing
DAll orders for customer with ID 42
Step-by-Step Solution
Solution:
  1. Step 1: Understand parameter binding effect

    The placeholder '?' is replaced safely with the value 42 during execution.
  2. Step 2: Predict query result

    The query returns all rows where customer_id equals 42, so matching orders are returned.
  3. Final Answer:

    All orders for customer with ID 42 -> Option D
  4. Quick Check:

    Parameter binding returns matching rows = All orders for customer with ID 42 [OK]
Quick Trick: Parameter '?' safely inserts value to filter results [OK]
Common Mistakes:
  • Thinking unnamed parameters cause errors
  • Assuming no results without named parameters
  • Believing all rows are returned regardless

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes