insert into temp (ids,user_ids ,user_id,phone,type) select '1sd212',u.ids,u.user_ids,u.telephone,1 from ( coupon_dtl cd left join coupon c on cd.coupon_id = c.coupon_id ) left join mst_users u on u.ids = cd.user_ids where u.delete_flag=0 and c.coupon_type=1 and cd.active_state = 1 and datediff(c.coupon_active_date,now()) >= 3;
这句sql提示警告,也可以插入数据,就是一直报警告,求解
这句sql提示警告,也可以插入数据,就是一直报警告,求解
`ids` varchar(50) NOT NULL,
`user_ids` varchar(32) NOT NULL,
`user_id` varchar(32) NOT NULL COMMENT '用户id',
`type` decimal(10,0) NOT NULL DEFAULT '0' COMMENT '结果类型',
`phone` varchar(32) NOT NULL COMMENT '手机号',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
PRIMARY KEY (`ids`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='添加定时任务扫描结果表,用于闲时定时扫描需要的结果,存放在此表中'
可能是select '1sd212',u.ids,u.user_ids,u.telephone,1 from...这中间的几个字段的值长度超过了你temp表的字段的长度,所以报错的。
`ids` varchar(32) NOT NULL,
`user_ids` varchar(20) NOT NULL COMMENT ,
`user_nm` varchar(20) DEFAULT NULL,
`telephone` varchar(11) DEFAULT NULL COMMENT ,
`user_type` char(1) DEFAULT NULL COMMENT ,
`invite_code` varchar(50) DEFAULT NULL,
没看到长度问题
where u.delete_flag='0' and c.coupon_type='1' and cd.active_state = '1' and datediff(c.coupon_active_date,now()) >= '3;'
即where条件字段是字符型,均要加上引号。