How to delete lines from a table created by a custom module? I'm working on a custom module that has an admin form designed to contain a number of values.
age 21 => value, age 22 => value, etc.

The issue I'm having is that while I can add information to the table I've created through my form, I'm only supposed to have 1 possible value per age.
I dont know how to delete the old value before the new one is added.

This is what I have that adds info to my table successfully:

/**
* Saving Score administration settings and DB information
*/
function savingsscore_admin_form() {
  $form = array();
$form['savings_ages'] = array(
  '#type' =&gt; 'fieldset', 
  '#title' =&gt; t('Saving Ages'), 
  '#weight' =&gt; -1, 
  '#collapsible' =&gt; TRUE, 
  '#collapsed' =&gt; FALSE,
  '#description' =&gt; t('Description of fields in this fieldset here'),
);
$form['savings_ages']['saving_age21'] = array(
'#type' =&gt; 'textfield',
'#title' =&gt; t('21'),
'#size' =&gt; 10,
'#maxlength' =&gt; 10,
'#default_value' =&gt; '10.85',
);
  return $form;
}

/**
* Handle submission of Admin forms
*/
function savingsscore_admin_form_submit($form, &amp;$form_state) {
db_query("INSERT INTO {savingfactors} (saving_age21)
VALUES ('%s')",
  $form_state['values']['saving_age21']);

drupal_set_message(t('Your form has been saved.'));
}


I know that what happens next should start like:

 db_query("DELETE FROM


But I dont know what I should add next, I'm uncertain of the syntax.
Any help or links to documentation would be much appreciated

Thanks
Stephanie
You will find an answer here.

Basically you can use Drupal's drupal_write_record() to let Drupal handle that.

Or you can run a SELECT query first and an UPDATE or INSERT based on SELECT's result.

EDIT:

Based on information gathered in comments, it seems that the "savingfactors" table has several columns and only one row. If the row is already present, with any value, then a simple UPDATE query is enough. Here's an example:

function savingsscore_admin_form_submit($form, &amp;$form_state) {
  db_query("UPDATE {savingfactors} SET saving_age21 = '%s'", $form_state['values']['saving_age21']);
  drupal_set_message(t('Your form has been saved.'));
}


That way you overwrite only saving_age21 field, ignoring others.

You can do the same with any other field you want to save.

There's an initial requirement: the row must exist. You can manually create it with a db client software, or you can implement Drupal's hook_install() inside your module .install file.