【问题标题】:Insert date and time as unix_timestamp in Mysql在 Mysql 中将日期和时间作为 unix_timestamp 插入
【发布时间】:2014-12-17 18:39:06
【问题描述】:

我正在尝试将当前日期和时间插入到 activitystamp 作为 unix_timestamp。但我得到的结果是 0。

INSERT INTO `skadate`.`ow_base_user_online` (`id`, `userId`, `activityStamp`, `context`, `misc`) 
VALUES (NULL, '1402', 'UNIX_TIMESTAMP()', '1', '1');

【问题讨论】:

  • 你没有调用函数。您正在传递一个字符串,其中包含看起来像函数调用的文本。

标签: mysql sql sql-insert unix-timestamp


【解决方案1】:

MySQL 函数应该用引号引起来:

INSERT INTO `skadate`.`ow_base_user_online` (`id`, `userId`, `activityStamp`, `context`, `misc`) 
VALUES (NULL, '1402', UNIX_TIMESTAMP(), '1', '1');

【讨论】:

  • 通常就是这么简单的事情:)
猜你喜欢
  • 1970-01-01
  • 2011-02-25
  • 1970-01-01
  • 1970-01-01
  • 2014-02-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多