Replace
REPLACE INTO students (roll, name, marks) VALUES (12, 'Asha', 90); if roll 12 exists, MySQL deletes that row and inserts the new one (PK/UNIQUE clash). It is not an in-place UPDATE — triggers and FKs behave like delete + insert.
Prefer INSERT … ON DUPLICATE KEY UPDATE when you want to keep the same row id and only change columns. REPLACE can break child rows.
Trap — using REPLACE as a casual synonym for UPDATE.
On the example next to this theory: Replace: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
Exam tip
REPLACE is delete+insert on key clash. Upsert with ON DUPLICATE KEY UPDATE.