Page 1 of 1

how can i empty the data in only one column of my table?

Posted: Sun Jun 24, 2007 9:39 pm
by robster
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi there, here is an example of my table:
[syntax="sql"]
TABLE `clients` (                                    
           `id` int(11) NOT NULL auto_increment,                     
           `name_first` varchar(50) NOT NULL default '',             
           `name_initial` varchar(5) default NULL,                   
           `name_last` varchar(50) NOT NULL default '',              
           `phone_work` varchar(50) default NULL,                    
           `phone_home` varchar(50) default NULL,                    
           `phone_mobile` varchar(50) default NULL,                  
           `email` varchar(100) default NULL,                        
           `recieve_emails` varchar(10) NOT NULL default '',         
           `confirmation` varchar(50) NOT NULL default '',           
           `cc_num` varchar(50) default NULL,                        
           `cc_month` varchar(50) default NULL,                      
           `cc_year` varchar(50) default NULL,                       
           `referral_type` varchar(50) NOT NULL default '',          
           `referral_notes` varchar(200) default NULL,               
           `add_street` varchar(150) default NULL,                   
           `add_city` varchar(50) default NULL,                      
           `add_state` varchar(50) default NULL,                     
           `add_pcode` varchar(20) default NULL,                     
           `gender` varchar(20) NOT NULL default '',                 
           `bday_day` varchar(50) NOT NULL default '',               
           `bday_month` varchar(50) default NULL,                    
           `bday_year` varchar(50) default NULL,                     
           `occupation` varchar(50) default NULL,                    
           `type` varchar(50) default NULL,                          
           `visible` tinyint(1) default NULL,                        
           `pref_colour` varchar(50) default NULL,                   
           `pref_massage` varchar(50) default NULL,                  
           `pref_beauty` varchar(50) default NULL,                   
           `notes_medical` mediumtext,                               
           `notes_formula` mediumtext,                               
           `notes_notes` mediumtext,                                 
           PRIMARY KEY  (`id`)                                       
         ) ENGINE=MyISAM AUTO_INCREMENT=1752 DEFAULT CHARSET=latin1  

I have a whole lot of waste/left over data in the VISIBLE column and I want to remove just the contents of the VISIBLE column.

How would I go about doing that whilst leaving the rest of the table intact?

Any advice really appreciated

Rob


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sun Jun 24, 2007 9:42 pm
by feyd
Do you want to remove the column (i.e. alter the table) or do you want to update the content to "empty" the column?

Posted: Sun Jun 24, 2007 9:54 pm
by Benjamin

Code: Select all

UPDATE clients SET visible = NULL

Posted: Sun Jun 24, 2007 10:27 pm
by robster
thank you so much :)

Of course it would be that easy, just had to find out how :)

Thanks again!

Rob