update newscontent set pubdate = (select datediff(s, '1970-01-01 00:00:00', intime))我想把intime里面的时间(格式为2010-01-01 00:00:00)修改为unix时间戳并添加到pubdate里。执行的时候出现1064错误#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' intime))' at line 1MySQL 客户端版本: 5.0.51aphpMyAdmin 版本信息: 3.3.10windows服务器

解决方案 »

  1.   

    Select UNIX_TIMESTAMP('2010-01-01 00:00:00');
      

  2.   

    mysql> Select UNIX_TIMESTAMP('2010-01-01 00:00:00');
    +---------------------------------------+
    | UNIX_TIMESTAMP('2010-01-01 00:00:00') |
    +---------------------------------------+
    |                            1262275200 |
    +---------------------------------------+
    1 row in set (0.00 sec)
      

  3.   

    我错了。。是ms sql的语句。。
      

  4.   

    MSSQL的话应该直接是这样的吧:
    update newscontent set pubdate =datediff(s, '1970-01-01 00:00:00', intime)
      

  5.   

    update newscontent 
    set pubdate =  datediff(s, '1970-01-01 00:00:00', intime)
      

  6.   

    update newscontent set pubdate = UNIX_TIMESTAMP(intime)