dimanche 14 février 2016

SQLite update is exists else update

I know this has been asked before but I am a complete neewbie at sql and I need it explained in simple terms.

How do I insert a new row if the primary key does not already exist in SQLite? e.g.

IF EXISTS(SELECT* FROM Live_Data WHERE Phone_ID = 'somevalue')
UPDATE Live_Data SET Location = 'LocationValue' WHERE Phone_ID = 'somevalue'
ELSE
INSERT INTO Live_Data Phone_ID = 'somevalue', Location = 'LocationValue'

Aucun commentaire:

Enregistrer un commentaire