开发者

mysql how to NOT update datetime?

开发者 https://www.devze.com 2023-01-12 15:39 出处:网络
I have a table where it has two datetimes, one of them is a \'completed\' datetime, therefore, if it is NULL the开发者_JAVA技巧n the user has not completed.

I have a table where it has two datetimes, one of them is a 'completed' datetime, therefore, if it is NULL the开发者_JAVA技巧n 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):

UPDATE YOUR_TABLE
   SET mobile_number = '123-456-7890'

The caveat is that if you have a DEFAULT ON UPDATE TIMESTAMP constraint set on the datetime column, the datetime column value will update to when the UPDATE statement was run. If you don't want this, you need to correct the DEFAULT constraint on the datetime column.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号