sql - SQLite Insert OR update without losing record data -
i have table "test" primary keys on "id & "lang"
╔════╦══════╦══════╦═══════╗ ║ id ║ lang ║ test ║ test2 ║ ╠════╬══════╬══════╬═══════╣ ║ 1 ║ zh ║ lol3 ║ lol4 ║ ║ 1 ║ en ║ lol ║ qsdf ║ ╚════╩══════╩══════╩═══════╝
and want insert or update since cannot if statement im left out inser or replace into
when run query :
insert or replace test (id,lang,test) values (1,'en','zaki')
i this
╔════╦══════╦══════╦════════╗ ║ id ║ lang ║ test ║ test2 ║ ╠════╬══════╬══════╬════════╣ ║ 1 ║ zh ║ lol3 ║ lol4 ║ ║ 1 ║ en ║ zaki ║ <null> ║ ╚════╩══════╩══════╩════════╝
it deletes record , inserts new 1 available data ( documentation of sqlite states. ) want keep value of test2 ( without knowing need keep value of test2 ) know value replace not keep. possible not lose data pass through (in 1 query).
it seem primary key on (id, lang)
, query found existing record id = 1, lang = 'en'
, did replace
on using data specified.
Comments
Post a Comment