Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

null value for all rows of a column!

Tags:

database

mysql

Is there any way for setting all the rows of a column to a null value? thanks

like image 269
user329820 Avatar asked Oct 24 '25 03:10

user329820


2 Answers

How about something simple like : Update MyTable Set MyColumn = NULL

Or, did you mean you wanted to set all columns in a row to NULL? If so, you have a database design problem. You should greatly limit what columns in a database accept NULL values.

like image 83
Randy Minder Avatar answered Oct 26 '25 20:10

Randy Minder


Sure.

UPDATE table SET column = NULL

If you don't include a WHERE clause, the statement will affect all the rows in the table.

like image 36
Syntactic Avatar answered Oct 26 '25 21:10

Syntactic