nasia jaffri
nasia jaffri

Reputation: 823

Replacing NULLS by some value in a SQL table

I have a table in SQLite3 database (using Python), Tweet Table (TwTbl) that has some values in the column geo_id. Most of the values in this column are NULL\None. I want to replace/update all NULLS in the geo_id column of TwTbl by a number 999. I am not sure about the syntax. I am trying the following query, but I am getting an error ("No such Column: None")

c.execute("update TwTbl SET geo_id = 999 where geo_id = None").fetchall()

I even tried using Null instead of None, that did not give any errors but did not do any update. Any help will be appreciated.

Upvotes: 0

Views: 93

Answers (1)

g.d.d.c
g.d.d.c

Reputation: 48028

As an answer, so that you can accept it if you're inclined.

You need Is Null instead of = Null. Null is a special value that's indeterminate, and neither equal nor non-equal in most database implementations.

Upvotes: 1

Related Questions