Reputation: 2687
I have a problem about inserting values into the table with sqlite. supposing the table:
create table test
{
KeyName varchar(50) primary key,
KeyValue varchar (255)
};
I want to insert data like ('john', 'friend')
, but I don't know whether the 'john'
existed.
Currently I solve it:
I'd like to know whether there is better solution? thanks
Upvotes: 1
Views: 80
Reputation: 154
you can use insert or replace which replaces the record if it already exists.
so you query be INSERT OR REPLACE INTO
check this link : http://www.sqlite.org/lang_conflict.html
Upvotes: 4