zoukankan      html  css  js  c++  java
  • MySQL:Data truncated for column 'last_apply_time' at row 1

    最近在执行一个更新语句时报这个错误:Caused by: java.sql.SQLException: Data truncated for column 'last_apply_time' at row 1。

    查百度说主要原因是建表的列为特定类型,而所插入的数据类型没与其字段一一对应

    原先使用的sql语句为:

    UPDATE jc_supplier_funds SET last_apply_time =  IFNULL((SELECT create_time FROM jc_jiesuan WHERE current_oprerate_type      > 0 AND supplier_id =  'f6e7d269-3798-4f' AND status = 1 ORDER BY create_time desc LIMIT 1),0)   WHERE supplier_id = 'f6e7d269-3798-4f' ;

    通过查询这两个表的DDL发现:

    jc_supplier_funds `last_apply_time` int(11) DEFAULT '0' COMMENT '上次申请时间',

    jc_jiesuan `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '申请时间',

    虽然这两个字段都是表示时间,但在数据库存的时候有的属性不同导致了该问题!

     sql修改为:

    UPDATE jc_supplier_funds SET last_apply_time =  IFNULL((SELECT UNIX_TIMESTAMP(create_time) FROM jc_jiesuan WHERE current_oprerate_type      > 0 AND supplier_id =  'f6e7d269-3798-4f' AND status = 1 ORDER BY create_time desc LIMIT 1),0)   WHERE supplier_id = 'f6e7d269-3798-4f' ;

    就没有问题了。

  • 相关阅读:
    beautiful number 数位DP codeforces 55D
    最长上升子序列
    0-1背包 codeforces 55 D
    概率DP HDU 4586 play the dice
    水题 不要62 HDU 2089
    抓老鼠 codeForce 148D
    ZOJ 3551 吸血鬼 概率DP
    poj 2151 Check the difficulty of problems 概率DP
    HDU 4681 string 求最长公共子序列的简单DP+暴力枚举
    HDU 1814 模板题 2-sat
  • 原文地址:https://www.cnblogs.com/sunzhenchao/p/2772809.html
Copyright © 2011-2022 走看看