UPDATE products SET price = price * 1.1 RETURNING;
medium
A. RETURNING cannot be used with UPDATE statements.
B. The multiplication operator * is invalid in UPDATE.
C. Missing WHERE clause causes syntax error.
D. RETURNING clause requires columns or * to specify what to return.
Solution
Step 1: Check RETURNING syntax
RETURNING must be followed by column names or *; empty RETURNING is invalid syntax.
Step 2: Validate other parts
Multiplication and UPDATE without WHERE are valid; RETURNING with no columns is the error.
Final Answer:
RETURNING clause requires columns or * to specify what to return. -> Option D
Quick Check:
RETURNING needs columns or * [OK]
Hint: Always specify columns or * after RETURNING [OK]
Common Mistakes:
Leaving RETURNING empty
Thinking WHERE is mandatory for syntax
Believing RETURNING disallowed in UPDATE
5. You want to increase the salary by 10% for employees in department 5 and get their id and new salary. Which query correctly does this and returns the updated rows?
hard
A. UPDATE employees SET salary = salary * 1.1 WHERE department_id = 5 RETURNING id, salary;
B. UPDATE employees SET salary = salary + 10 WHERE department_id = 5 RETURNING *;
C. UPDATE employees SET salary = salary * 1.1 RETURNING id, salary WHERE department_id = 5;
D. UPDATE employees SET salary = salary * 1.1 WHERE department_id = 5 RETURN id, salary;
Solution
Step 1: Identify correct UPDATE with WHERE and RETURNING
The query must update only department 5 employees and return id and salary.
Step 2: Check syntax correctness
UPDATE employees SET salary = salary * 1.1 WHERE department_id = 5 RETURNING id, salary; uses correct syntax: UPDATE ... SET ... WHERE ... RETURNING id, salary;
Step 3: Eliminate incorrect options
Adding a fixed 10 instead of multiplying by 1.1 doesn't implement a 10% increase. Placing RETURNING before WHERE is invalid syntax. Using RETURN instead of RETURNING is wrong.
Final Answer:
UPDATE employees SET salary = salary * 1.1 WHERE department_id = 5 RETURNING id, salary; -> Option A
Quick Check:
Correct syntax with WHERE and RETURNING columns [OK]
Hint: RETURNING follows WHERE clause with columns listed [OK]
Common Mistakes:
Placing RETURNING before WHERE
Using RETURN instead of RETURNING
Adding fixed amount instead of percentage
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.