Reputation: 55293
I know how to make a column null:
UPDATE company_master SET company_info_html = NULL
But what can I do if I want to make all the fields of a table NULL?
I'm using phpmyadmin.
Upvotes: 0
Views: 442
Reputation: 2492
I can't think of any reason why probably you would need to do something like that .
However to do that ( even if you are using PHPMyAdmin ) you would need to include all those columns in the query :
UPDATE
`company_master`
SET
`column_1` = NULL ,
`column_2` = NULL ,
`column_3` = NULL
WHERE
column_1 = 1
( Replace column_1 , column_2 , etc with the actual column names )
If you are intending to do that for all the rows in a table then remove the where clause :
UPDATE
`company_master`
SET
`column_1` = NULL ,
`column_2` = NULL ,
`column_3` = NULL
But then you might end up with an error as at least one of those columns could have primary or unique key constraint . For example in my test the first column has Primary Key constraint :
#1062 - Duplicate entry '0' for key 'PRIMARY'
Upvotes: 1
Reputation: 6854
you can update multiple columns in the update statement if you list them (seperated by commas) after the SET
. however this is pretty useless because all rows will end up being the same and duplicates should be removed. so you end up with one row of nulls. to achieve this more easily you could truncate the table and insert one empty row (with default values) or one row of nulls...
Upvotes: 0