Vishnu Prabhu Vishnu Prabhu - 1 month ago 8
MySQL Question

How insert a value only for Null set in a column in a table in MYSQL Database

I am facing a small problem in updating a value in a column in a table in MysqlDatabase.

UPDATE table_name

SET Column_name = "572"
where column_name is null;

Can any help me what is wrong in this statement.

I am new to sql.

Thank you

Answer

You are selecting data not updating.

For update you have to use update command.

UPDATE table_name 
SET col_name= 'col_value'
WHERE col_name IS NULL

or

UPDATE table_name 
SET col_name= 'col_value'
WHERE col_name=''