I am trying to run simple query for sqlite which is update a record if not exists.
I could have used Insert or replace
but article_tags
table doesn't have any primary key
as it is a relational table.
How can I write this query for sqlite
as if not exists
is not supported.
And I don't have idea how to use CASE for this ?
Table Structure:
articles(id, content)
article_tags(article_id, tag_id)
tag(id, name)
SQLITE Incorrect Syntax Tried
insert into article_tags (article_id, tag_id ) values ( 2,7)
if not exists (select 1 from article_tags where article_id =2 AND tag_id=7)