How do I update or insert an sqlite row with multiple conditions -


i have 3 tables. a, b, , a_to_b. relationship between , b many-to-many. relationship information stored in table a_to_b. it's construction defined follows:

create table (id integer primary key autoincrement not null,  identifier_from_a text not null,  identifier_from_b text not null); 

each relationship unique.

i persist relationship data single statement per relationship. question is, how can achieve without inserting duplicates?

the solution use multiple column unique definition in create table statement.

for example:

create table (id integer primary key autoincrement not null,  identifier_from_a text not null,  identifier_from_b text not null, unique (a,b) on conflict replace); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -