创建表数据
CREATE TABLE `praise_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`pic_id` varchar(64) DEFAULT NULL COMMENT '图片ID',
`created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`),
KEY `pic_id` (`pic_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3647 DEFAULT CHARSET=utf8 COMMENT='图片表';
添加数据省略
时间轴前2条数据
SELECT * FROM
(
SELECT *, @num := if(@created_time = DATE_FORMAT(created_time, '%Y-%m-%d'), @num := @num + 1, 1) as row_num,
@created_time := DATE_FORMAT(created_time, '%Y-%m-%d') as axisTime FROM praise_info
order by id desc
) AS temp
WHERE row_num < 3;
原文链接:https://www.cnblogs.com/snail001/p/11194752.html
如有疑问请与原作者联系
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有