statement
MERGE
Synchronizes matching rows; a target row must not be modified more than once by the source. This example changes an existing order, not an upsert guarantee. Example target: PostgreSQL 17. Use only the isolated starter dataset; setup and expected results are in the batch evidence.
Formal Syntax & Structure
sql syntaxsql
MERGE INTO target USING source ON condition WHEN MATCHED THEN UPDATE SET column = expressionWorking Example
Example Snippetsql
MERGE INTO orders AS t USING (VALUES (101, 140)) AS s(id, amount) ON t.id = s.id WHEN MATCHED THEN UPDATE SET amount = s.amount;