0

I have four columns in a table. I am using sqlite database and I want to delete data of three columns and keep the data of other one column.

String sql="DELETE  january,deducted,remaining FROM sailary where id=?";

try
{
    pst = conn.prepareStatement (sql);
    pst.setString (1, jut.getText());
    pst.execute();
}
catch(Exception e)
{
    JOptionPane.showMessageDialog(null, e);
}
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • 2
    You can't delete columns from a single row. Do you want to remove/reset the *values* of the columns in a particular row, or do you want to remove those columns from the entire table? – Paul Roub Aug 03 '14 at 18:11
  • possible duplicate of [How to delete or add column in SQLITE?](http://stackoverflow.com/questions/8442147/how-to-delete-or-add-column-in-sqlite) – bmargulies Aug 10 '14 at 16:02

1 Answers1

2

delete is used to remove rows. What you could do is update these columns to be null in the specific row you're referring to:

UPDATE sailary
SET    january = NULL, deducted = NULL, remaining = NULL
WHERE  id = ?
Mureinik
  • 297,002
  • 52
  • 306
  • 350