I have a table where it has two datetimes, one of them is a ‘completed’ datetime, therefore, if it is NULL then the user has not completed.
I am trying to do an update, to update their mobile number.
How can i do it so it does not update the datetime?
currently if the datetime is null it gets set to the earliest possible time.
here is my query:
mysql_query("UPDATE action_4_members
SET `mobile` = '{$mobile}',
`additional_txt` = '{$additional}',
`misc_data` = '{$store_id}'
WHERE `id` = '{$member_id}'") or die(mysql_error());
here is my table definition:
CREATE TABLE `action_4_members` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`campaign_id` int(11) DEFAULT NULL,
`mobile` varchar(25) DEFAULT NULL,
`join_txt` varchar(160) DEFAULT NULL,
`join_txt_date` datetime DEFAULT NULL,
`additional_txt` varchar(160) DEFAULT NULL,
`additional_txt_date` datetime DEFAULT NULL,
`misc_data` text,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=687 DEFAULT CHARSET=latin1
An UPDATE statement will only affect the column(s) you specify (with one caveat):
The caveat is that if you have a
DEFAULT ON UPDATE TIMESTAMPconstraint set on the datetime column, the datetime column value will update to when theUPDATEstatement was run. If you don’t want this, you need to correct the DEFAULT constraint on the datetime column.