Gaurav Sharma
Gaurav Sharma

Reputation: 2848

select and then insert in sqlite table

I am trying to insert records into a sqlite table where in I have to first run a select query on the table and if the record does not exists then insert it.

Is there an efficient way of doing this?

Upvotes: 2

Views: 371

Answers (1)

trickwallett
trickwallett

Reputation: 2468

Looks like INSERT OR REPLACE would suit you here aka REPLACE in MySQL.

See:

http://www.sqlite.org/lang_replace.html

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

Upvotes: 2

Related Questions