techie
techie

Reputation: 467

Deal with null value in sqlite

I want to insert a zero in a record that contains a null value by updating that table. I have used the following code but to no avail.

Statement statementXIV = db.createStatement("UPDATE Temp54 SET bal53 = '0' WHERE balan = NULL ");
                    statementXIV.prepare();
                    statementXIV.execute();       
                    statementXIV.close();

What is the right way to use a null in a WHERE clause?

Upvotes: 1

Views: 2481

Answers (1)

CM Kanode
CM Kanode

Reputation: 1436

I would suggest using:

UPDATE Temp54 SET bal53 = '0' WHERE balan IS NULL OR balan = ''

Also, see this link, SQLite select where empty?. The accepted answer gives a variety of methods which is always good to know.

Upvotes: 1

Related Questions