tags:

views:

96

answers:

2

I am new to the iPhone and have a problem with SQLite...
I want to execute a query which contains multiple where conditions like:

UPDATE tablename 
   SET field1 = ?, 
       field2=? 
 WHERE Itemid=? 
   AND field1=? 
   AND field2=?

Is this is the right way to do the update? If possible what would be the code to execute the query?

+1  A: 

Take out the iPhone aspect and try running/testing your queries in an SQLite administration tool.

Mark Redman
A: 

Is this is the right way to do the update?

Yes, an UPDATE statement is the correct way to update existing data in a SQL table.

The only thing that isn't clear is if the columns listed in your WHERE clause exist in the table you are attempting to update. A common convention for checking the columns in a table is to use DESCRIBE [table name] (IE: DESCRIBE tablename), but SQLite doesn't support the DESCRIBE syntax - you'd have to use:

pragma table_info ( table_name );
OMG Ponies