0

Possible Duplicate:
INSERT IF NOT EXISTS ELSE UPDATE?

I want to check if a row (with it's ID) exists in a database, if yes, I want to update the column category, if it does not exist, i want to add a new row. Is this possible via a single query in sqlite (will be applied inside eclipse using java for an android app)

Community
  • 1
  • 1
Dan Jurgen
  • 927
  • 1
  • 8
  • 13

1 Answers1

0

I think that it's not possible. First you have to execute a query to check if a row exist, if yes, execute an update statement, if not, execute an insert statment...i think this are the way to go...

if(existsId(id)){
   updateCategory(categoryValue);
}else{
   addNewRow(newRowData);
}
jzafrilla
  • 1,416
  • 3
  • 18
  • 41