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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

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

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

UPDATE clients SET visible = NULL
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

thank you so much :)

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

Thanks again!

Rob
Post Reply