
sql多表查询语句,显示不重复数据
首先是写在sql的存储过程中,然后我有两个表,其一是文章,其二是留言,我要把这两个表连接起来查询,我的语句是:ALTERPROCEDURE[dbo].[pro_GetTe...
首先是写在sql的存储过程中,然后我有两个表,其一是文章, 其二是留言,我要把这两个表连接起来查询,我的语句是:
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 and text_Text.tId in(select distinct tId from text_Text)
END
可查询出的还是重复的数据,想问下该怎么改呢?
就是每个重复的都只显示一次 展开
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 and text_Text.tId in(select distinct tId from text_Text)
END
可查询出的还是重复的数据,想问下该怎么改呢?
就是每个重复的都只显示一次 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询