Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to use a parameter placeholder in the SQL query.
SQL
SELECT * FROM users WHERE username = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using named placeholders when the library expects positional ones.
Forgetting to use any placeholder and inserting values directly.
✗ Incorrect
The question mark ? is a common placeholder for parameters in SQL queries.
2fill in blank
mediumComplete the code to bind a named parameter in the SQL query.
SQL
SELECT * FROM products WHERE category = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using positional placeholders instead of named ones.
Omitting the colon before the parameter name.
✗ Incorrect
Named parameters use a colon : followed by the parameter name.
3fill in blank
hardFix the error in the SQL query by choosing the correct parameter placeholder.
SQL
UPDATE orders SET status = [1] WHERE order_id = 123;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using question marks in PostgreSQL queries.
Using named parameters without support in the database.
✗ Incorrect
In PostgreSQL, positional parameters use $1, $2, etc.
4fill in blank
hardFill both blanks to correctly bind parameters for a user login query.
SQL
SELECT * FROM users WHERE email = [1] AND password = [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing positional and named parameters in the same query.
Using question marks for named parameters.
✗ Incorrect
Named parameters :email and :password are used to bind values safely.
5fill in blank
hardFill all three blanks to create a parameterized INSERT statement.
SQL
INSERT INTO employees (name, age, department) VALUES ([1], [2], [3]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using question marks for some parameters and named for others.
Not matching parameter names to column names.
✗ Incorrect
Use named parameters :name, :age, and :department to safely insert values.