-- *** before: ***
-- the application checked the row first and then chose INSERT or UPDATE
SELECT COUNT(*) FROM city WHERE ID = 1;
-- and then one of the two statements
-- *** in version 2003: ***
MERGE INTO city AS t
USING city_import AS s ON t.ID = s.ID
WHEN MATCHED THEN
UPDATE SET Population = s.Population
WHEN NOT MATCHED THEN
INSERT (ID, Name, CountryCode, Population)
VALUES (s.ID, s.Name, s.CountryCode, s.Population)
-- Support: Oracle 9i, MS SQL Server 2008, Firebird 2.1 and PostgreSQL
-- 15. MySQL solves the same task with INSERT ... ON DUPLICATE KEY
-- UPDATE, SQLite with INSERT ... ON CONFLICT DO UPDATE since 3.24.
-- Access has neither.