CREATE TABLE `tt_transfer_container_pick_config` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `yard_code` varchar(11) NOT NULL DEFAULT '' COMMENT '场地代码', ... `version` bigint(20) DEFAULT NULL COMMENT '版本号', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`), KEY `idx_yard_code` (`yard_code`) USING BTREE COMMENT '场院代码索引', ... KEY `idx_create_time` (`create_time`) USING BTREE COMMENT '创建时间索引', KEY `idx_update_time` (`update_time`) USING BTREE COMMENT '更新时间索引' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='容器分拣配置表';
查询时出问题的就是这张表
出错的查询语句
SELECT * FROM tt_transfer_container_pick_config WHERE yard_code = '735VA' AND ... AND is_delete = 0 AND invalid_time > NOW() ORDER BY update_time DESC LIMIT 1, 10;
order by update_time DESC咋一看没有问题,update_time 是每次都是由mysql自动更新的,感觉会一直递增
SELECT * FROM tt_transfer_container_pick_config WHERE yard_code = '735VA' AND ... AND is_delete = 0 AND invalid_time > NOW() ORDER BY id ASC, update_time DESC LIMIT 1, 10;