1623. Delete duplicates safely — Hotel — implementation variant 23

DBMS Published Updated 0 Views Verified
In a Hotel application, implement this production problem: Delete duplicate customers while keeping the smallest ID for each email. The API/service receives user input and must return or modify data safely. Give the SQL solution, explain why it works, and show how the same operation is called from the selected stack.
Looking for the latest Sarkari Result 2026 updates? Check the latest government exam results, merit lists and result updates on Sarkari Resultess.
Sarkari Resultess
Questions & Answers

Answer & Explanation

4 Answers
Verified

Option A

UPDATE the_table SET status='active';
Additional Explanation
Incorrect: it does not implement the stated business rule and may modify/fetch the wrong rows.
Sarkari Resultess
Editorial Answer 1
Verified Correct Answer

Option B

DELETE c1 FROM customers c1 JOIN customers c2 ON c1.email=c2.email AND c1.id>c2.id WHERE c1.email IS NOT NULL;
Additional Explanation
The self-join identifies later duplicate IDs. Preview with SELECT and use a backup/transaction before deletion.
Sarkari Resultess
Editorial Answer 2
Verified

Option C

DELETE FROM the_table;
Additional Explanation
Incorrect: it does not implement the stated business rule and may modify/fetch the wrong rows.
Sarkari Resultess
Editorial Answer 3
Verified

Option D

SELECT * FROM the_table;
Additional Explanation
Incorrect: it does not implement the stated business rule and may modify/fetch the wrong rows.
Sarkari Resultess
Editorial Answer 4