JoeJam
JoeJam

Reputation: 371

How to update blank rows

I have a table with data (stored as INTEGER) with some NULL values. I want to set all NULL values to 0.

I tried UPDATE table SET data = 0 WHERE (data = '') IS NOT FALSE;

Apparently this only works for strings. Any ideas where the data is type integer or numeric?

Upvotes: 0

Views: 87

Answers (1)

JoeJam
JoeJam

Reputation: 371

As @joop pointed out, integer values are NULL not blank. The following worked to delete all NULL rows.

UPDATE table 
SET data = 0 WHERE data IS NULL;

Upvotes: 2

Related Questions