mysql 根据子查询 进行 编写 修改语句
update nvr_downfailed INNER JOIN( select nvr_restartnum from nvr_downfailed where downfile_id =(select max(downfile_id) from nvr_downfailed) ) b on nvr_downfailed.nvr_restartnum=b.nvr_restartnum set nvr_downfailed.nvr_restarttime=NOW(),nvr_downfailed.nvr_restartnum=b.nvr_restartnum+1 where downfile_id=437285
/* Navicat MySQL Data Transfer Source Server : 127.0.0.1 Source Server Version : 50635 Source Host : localhost:3306 Source Database : zichuannvrdownload Target Server Type : MYSQL Target Server Version : 50635 File Encoding : 65001 Date: 2021-05-21 18:38:29 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `nvr_downfailed` -- ---------------------------- DROP TABLE IF EXISTS `nvr_downfailed`; CREATE TABLE `nvr_downfailed` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键自增id', `downfile_id` int(11) NOT NULL COMMENT '下载失败的记录值', `check_time` datetime DEFAULT NULL COMMENT '数据检测时间', `land_id` int(11) DEFAULT NULL COMMENT '车道号', `down_start` datetime DEFAULT NULL COMMENT '下载开始时间', `down_end` datetime DEFAULT NULL COMMENT '下载结束时间', `down_fildtime` datetime DEFAULT NULL COMMENT '下载失败时间', `down_newnum` int(11) DEFAULT NULL COMMENT '重下次数', `down_newtime` datetime DEFAULT NULL COMMENT '重下时间', `con_upnum` int(11) DEFAULT NULL COMMENT '重传次数', `con_uptime` datetime DEFAULT NULL COMMENT '重传时间', `nvr_restarttime` datetime DEFAULT NULL COMMENT 'NVR重启时间', `nvr_restartnum` int(11) DEFAULT NULL COMMENT 'NVR重启次数', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of nvr_downfailed -- ---------------------------- INSERT INTO `nvr_downfailed` VALUES ('1', '1', '2021-05-12 16:52:00', '1', '2021-05-12 16:52:00', '2021-05-12 16:52:00', '2021-05-12 16:52:00', '1', '2021-05-12 16:52:00', '1', '2021-05-12 16:52:00', '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('2', '437280', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 15:53:41', '2021-05-21 16:56:19', null, null, null, null, '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('3', '437280', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 15:53:41', '2021-05-21 17:05:27', null, null, null, null, '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('4', '437280', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 05:53:41', '2021-05-21 17:10:23', null, null, null, null, '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('5', '437280', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 15:53:41', '2021-05-21 17:12:06', null, null, null, null, '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('6', '437280', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 15:53:41', '2021-05-21 17:12:40', null, null, null, null, '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('7', '437280', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 15:53:41', '2021-05-21 17:13:42', null, null, null, null, '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('8', '437280', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 15:53:41', '2021-05-21 17:14:19', null, null, null, null, '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('9', '437280', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 15:53:41', '2021-05-21 17:17:00', null, null, null, null, '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('10', '437280', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 15:53:41', '2021-05-21 10:18:34', null, null, null, null, '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('11', '437281', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 15:53:41', '2021-05-21 17:16:40', null, null, null, null, '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('12', '437282', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 15:53:41', '2021-05-21 10:20:15', null, null, null, null, '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('13', '437283', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 15:53:41', '2021-05-21 10:21:41', null, null, null, null, '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('14', '437284', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 15:53:41', '2021-05-21 17:00:26', null, null, null, null, '2021-05-21 17:35:52', null); INSERT INTO `nvr_downfailed` VALUES ('15', '437285', '2021-04-28 15:53:37', '2', '2021-04-28 15:53:34', '2021-04-28 15:53:41', '2021-05-21 17:28:03', null, null, null, null, '2021-05-21 18:37:18', '2');