按照你给的代码,只要加个HAVING 就可以了。
比如下面所示:
ALTER PROCEDURE [dbo].[pro_GetText_One]
@firId int,
@secId int
AS
BEGIN
SELECT distinct text_Text.tId,text_Discuss.SendTime FROM text_Discuss inner JOIN
text_Text ON text_Discuss.tId = text_Text.tId where text_Text.firId=@firId and text_Text.secId=@secId
HAVING COUNT(text_Text.tId)>1
END
眼镜都看疼了,如果是对的,请多给点分!!
这得看你要哪些字段的数据了
你要明白,这两表的关系是一对多的关系,所以在查询的时候如果两表字段都有出现,必然会有重复的
ALTER PROCEDURE [dbo].[pro_GetText_One]
@firId int,
@secId int
AS
BEGIN
SELECT distinct text_Discuss.SendTime ,text_Text.tIdFROM text_Discuss inner JOIN
text_Text ON text_Discuss.tId = text_Text.tId where text_Text.firId=@firId and text_Text.secId=@secId and text_Text.tId in(select distinct tId from text_Text)
END
这样试一下
group by 语句.
SELECT text_Text.tId,text_Discuss.SendTime FROM text_Discuss inner JOIN
text_Text ON text_Discuss.tId = text_Text.tId where text_Text.firId=@firId and text_Text.secId=@secId group by text_text.tld
text_Text是留言表?