存储过程 Data truncation: Incorrect date value: ‘1988‘ for column ‘date‘ at row 1

最近写存储过程报错

网上搜都是说mysql sql脚本格式不对

我这里是存储过程,我在想时间也是对的啊,时间格式,为啥

原来的

 SET updateSQL = CONCAT("INSERT INTO data_bi.bi_user_catch_partake_day_static(date, room_id, vip, user_type, fish_id, factor_type, acc_num, first_acc_num)
            SELECT date, room_id, vip, user_type, fish_id, factor_type, count(account_id), count(if(is_new_acc = 1,account_id,null))
            FROM data_bi.bi_user_catch_partake_day_active WHERE date = ", theTime, "
            GROUP BY ", groupBySbStr, "
            ON DUPLICATE KEY UPDATE acc_num = VALUES(acc_num),first_acc_num = VALUES(first_acc_num)");
            call data_tslog.execute_sql(updateSQL);

大家有没有发现

其实少了引号,这里解析为2020-08-11,引号没有解析

SET updateSQL = CONCAT("INSERT INTO data_bi.bi_user_catch_partake_day_static(date, room_id, vip, user_type, fish_id, factor_type, acc_num, first_acc_num)
            SELECT date, room_id, vip, user_type, fish_id, factor_type, count(account_id), count(if(is_new_acc = 1,account_id,null))
            FROM data_bi.bi_user_catch_partake_day_active WHERE date = '", theTime, "'
            GROUP BY ", groupBySbStr, "
            ON DUPLICATE KEY UPDATE acc_num = VALUES(acc_num),first_acc_num = VALUES(first_acc_num)");
            call data_tslog.execute_sql(updateSQL);

希望能帮到你,我的博客:idearyou.cn

MySQL中,当尝试插入一个不正确的日期时间值时,会出现错误“Data truncation: Incorrect date value: 'null' for column 'hydate' at row 1”。这个错误的原因是在一个datetime类型的列中插入了一个空值``,而空值并不符合YYYY-MM-DD HH:MM:SS格式的要求。 你需要确保插入的值是一个符合格式的日期时间值,或者使用0000-00-00 00:00:00表示没有时间。 对于你提供的引用,我没有找到与错误相关的信息。请确保你的查询语句中的日期值正确,并且没有空值。如果问题仍然存在,你可以检查列的定义是否与插入的值匹配,并确保使用正确的语法和引号。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [Data truncation: Incorrect datetime value: ‘‘ for column ‘MODIFY_TIME‘ at row 1报错原因](https://blog.csdn.net/ChunwaiLeung/article/details/131965122)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [存储过程 Data truncation: Incorrect date value: ‘1988‘ for columndate‘ at row 1](https://blog.csdn.net/qq_33668999/article/details/108394191)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值