版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012555942/article/details/78131911
CREATE TABLE `lx_comment` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`article_id` int(11) NOT NULL COMMENT '文章ID',
`pid` int(11) NOT NULL DEFAULT '0' COMMENT '上级ID',
`type` enum('ios','android','pc','web') NOT NULL COMMENT '评论类型',
`uid` int(11) NOT NULL COMMENT '用户ID',
`status` int(11) NOT NULL DEFAULT '1' COMMENT '1 正常 2 审核不通过 -1 删除',
`created_at` int(11) NOT NULL COMMENT '创建时间',
`updated_at` int(11) NOT NULL COMMENT '更新时间',
`reply_uid` int(11) NOT NULL DEFAULT '0' COMMENT '回复目标ID',
`content` text NOT NULL COMMENT '评论内容',
`comment_id` int(11) NOT NULL DEFAULT '0' COMMENT '评论ID',
`good_num` int(11) NOT NULL COMMENT '点赞',
`level` int(11) NOT NULL COMMENT '等级',
PRIMARY KEY (`id`),
KEY `a_id` (`article_id`),
KEY `comment_id` (`comment_id`) USING BTREE
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`article_id` int(11) NOT NULL COMMENT '文章ID',
`pid` int(11) NOT NULL DEFAULT '0' COMMENT '上级ID',
`type` enum('ios','android','pc','web') NOT NULL COMMENT '评论类型',
`uid` int(11) NOT NULL COMMENT '用户ID',
`status` int(11) NOT NULL DEFAULT '1' COMMENT '1 正常 2 审核不通过 -1 删除',
`created_at` int(11) NOT NULL COMMENT '创建时间',
`updated_at` int(11) NOT NULL COMMENT '更新时间',
`reply_uid` int(11) NOT NULL DEFAULT '0' COMMENT '回复目标ID',
`content` text NOT NULL COMMENT '评论内容',
`comment_id` int(11) NOT NULL DEFAULT '0' COMMENT '评论ID',
`good_num` int(11) NOT NULL COMMENT '点赞',
`level` int(11) NOT NULL COMMENT '等级',
PRIMARY KEY (`id`),
KEY `a_id` (`article_id`),
KEY `comment_id` (`comment_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=166 DEFAULT CHARSET=utf8;
分页问题
先查出楼层ID
再进行子查询