sql - Always overwrite if exists? -


my table looks like:

_id, subid, textinput, attribute1, attribute2 

when create new record, saves 5 rows... same subid. if create record same subid, saves 5 rows, giving me total of 10 rows subid.

what if subid exists overwrite rows there. how go doing that?

you can use insert or replace, you'll have put unique index on subid.

alternatively, can query table subid , if found, use simple update instead. if not found, use standard insert.


Comments

Popular posts from this blog

Python __call__ special method practical example -

arrays - jQuery - Retrieve values from HTML elements and return their sum -