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' ;

    就没有问题了。

  • 相关阅读:
    C# 访问USB(HID)设备
    IPad C盘中backup文件夹占用太多空间
    fastboot
    adb get android's ip
    Reading MMS
    Bitcoin
    内存问题导致编译不过!
    串口LOG 单编kernel
    Source Insight 格式化
    framework层的空指针会让系统重启
  • 原文地址:https://www.cnblogs.com/sunzhenchao/p/2772809.html
Copyright © 2011-2022 走看看