2

We are creating an app wich uses local and remote DB, the information comes from the remote server and if necessary gets stored in the local DB. The problem is, some records, will come again to the local DB, and i dont want to duplicate the entry, just update it, and if does not exists, insert a new one. In Mysql i probably use :

INSERT INTO 'table'
('key', 'name', 'time')
VALUES
(4815162342, user, NOW())
ON DUPLICATE KEY UPDATE
'name' = newname

Is there a way to use it in SQLite, more specifically with FMDB?

darkman
  • 993
  • 3
  • 13
  • 31

1 Answers1

1

I think what you want is more generally referred to as an 'upsert'. See this answer for some recommendations (or search further as there's a bunch more around).

https://stackoverflow.com/a/15277374/297472

Community
  • 1
  • 1
Scott Corscadden
  • 2,831
  • 1
  • 25
  • 43