如何用一条select查询出主题的发表人、发表时间、回复总数、最后回复人、最后回复时间
如何用一条select查询出主题的发表人、发表时间、回复总数、最后回复人、最后回复时间表机构如下
tb_person 可简单认为有如下字段, id,name,
--31 create table tb_discussion
drop table if exists `tb_discussion`;
create table `tb_discussion`(
`id` integer not null auto_increment,
`title` varchar(300) not null,
`summary` longtext,
`participants` longtext,
`mailId` integer,
`dstate` varchar(10) ,
`createTime` datetime,
`closeTime` datetime,
`personId` integer not null,
primary key(`id`),
foreign key(`personId`) references `tb_party`(`id`)
);
--32 create table tb_comment
drop table if exists `tb_comment`;
create table `tb_comment`(
`id` integer not null auto_increment,
`content` longtext,
`commentTime` datetime,
`discussionId` integer not null,
`personId` integer not null,
primary key(`id`),
foreign key(`personId`) references `tb_discussion`(`id`),
foreign key(`personId`) references `tb_party`(`id`)
);