MySQL

Recommended:

INSERT INTO table (id, name, age) VALUES(1, "A", 19) ON DUPLICATE KEY UPDATE
name="A", age=19

Pros:

  1. Easy to understand
  2. Won't change the ID, friendly with auto-increment keys or unique keys
  3. Efficient.
  4. Only changed values need to be provided

Cons:

  1. Long statement.
  2. Doesn't work for non-UNIQUE or PRIMARY keys.

Alternative:

REPLACE into table (id, name, age) values(1, "A", 19)

Cite:http://dev.mysql.com/doc/refman/5.0/en/replace.html

Pros:

  1. Shorter statement, easy to understand.
  2. Works for all cases.

Cons:

  1. It's actually a delete and insert procedure internally.
  2. Slow and it changes the auto-increment id.
  3. All the fields have to be provided

Sqlite

Recommended

-- Try to update any existing row
UPDATE players SET user_name='steven', age=32 WHERE user_name='steven';
-- Make sure it exists
INSERT OR IGNORE INTO players (user_name, age) VALUES ('steven', 32);

Pros:
Works for all sqlite versions.

Cons:
Too long statement.

Alternative
This is a late answer. Starting from SQLIte 3.24.0, released on June 4, 2018, there is finally a support for UPSERT clause following PostgreSQL syntax.

INSERT INTO players (user_name, age)
VALUES('steven', 32)
ON CONFLICT(user_name)
DO UPDATE SET age=excluded.age;