I have the following table:
CREATE TABLE \'Test\' (\'Id\' INTEGER PRIMARY KEY NOT NULL, \'Val\' INTEGER)
If a given Id doesn\'t exist, I want t
You can use insert or replace.
I thinks this will do the trick
INSERT OR REPLACE INTO Test (Id,Val)
VALUES ( 1,
COALESCE((SELECT Val + 1 FROM Test WHERE id = 1), 1)
);
INSERT OR REPLACE INTO Test (Id,Val)
VALUES ( 2,
COALESCE((SELECT Val + 1 FROM Test WHERE id = 2), 1)
);
You just have to replace the numbers with your inputed id
Thanks Chico