這是我的論壇的帖子信息表
create table tiezi
(
tieziid int not null primary key identity(1,1),
userid int ,
tztitle varchar(20) not null,
tzcontent varchar(200)not null,
tztime datetime not null,
tztop varchar(1),
hfnum int
)
這是帖子的回復表
create table tzpinglun
(
pinglunid int not null primary key identity(1,1),
tieziid int not null,
tzpluserid int ,
tzplcontent varchar(200),
tzpltime datetime,
tzpltitle varchar(20)
)
如何能夠查詢出第一章表的所有內容同時連接第二章表查出回復數,這兩張表用tieziid相連
SELECT A.*,(select count(*) from tzpinglun where tieziid =A.tieziid ) as 回復數 FROM tiezi A