SQLite UPDATE


Now it is time to learn SQLite UPDATE, which is of course quite useful for when you need to change something in the row.

Here is an example:

/* $con is the SQLite Handle */
sqlite_query($con"UPDATE table SET title = 'New Title', content = 'New Content or w/e here!' 
WHERE id = 1"
$result_type$query_error);
if(!empty(
$query_error))
  echo 
$query_error;
else
  echo 
'Update Successful!';


Break it down
UPDATE table SET - UPDATE, its the command to update, replace table with the table you want to update, and SET is another reserved word.

title = 'New Title', content = 'New Content or w/e here!' - This is where you do like "column_to_update = 'What you want the new value to be'", you can update more then 1 column by separating them by commas.

WHERE id = 1 - This is where you choose what rows you want to be updated... If you want to update 1 specific row, and it has a similar row as another, you will need to find something that is unique to that row. You can also do WHERE id = 1 AND another_col = 'something else', you can also do OR as well.