Every language
1 linguagens, copy-ready. One at a time with syntax highlighting, or all inline.
SQLSQLrunnable
INSERT INTO users (id, email, name)
VALUES (42, 'ada@example.com', 'Ada')
ON CONFLICT (id) DO UPDATE
SET email = excluded.email,
name = excluded.name
RETURNING id, (xmax = 0) AS inserted_this_time;excluded holds the row that failed to insert — read the challenger's values from it, not from the table. ON CONFLICT DO NOTHING is the ignore-duplicates variant. Run it twice in the playground: first pass inserts (true), second pass updates (false).