注册 登录
编程论坛 SQL Server论坛

查询 数据只显示一次

跳过去 发布于 2012-11-11 20:22, 504 次点击
select PostComment.PostID from PostComment join CommentReply on PostComment.UserID=CommentReply.UserID where CommentReply.UserID=1 or PostComment.UserID=1
只有本站会员才能查看附件,请 登录

就如图那样的结果怎么让他 postID 1 4 5 7 只显示一次啊
5 回复
#2
跳过去2012-11-11 20:24
就像本论坛的 查询我参与过的主题一样
#3
cnfarer2012-11-12 06:50
distinct
#4
跳过去2012-11-12 20:49
回复 3楼 cnfarer
能不能写个整句的来看看
#5
lfylovey2012-11-13 13:59
SELECT DISTINCT PostComment.PostID
FROM PostComment JOIN
     CommentReply ON PostComment.UserID=CommentReply.UserID
WHERE CommentReply.UserID=1 OR
      PostComment.UserID=1
ORDER BY PostComment.PostID

#6
跳过去2012-11-25 17:27
回复 5楼 lfylovey
只有本站会员才能查看附件,请 登录

查询 UserID =2 所参与过的帖子 明明就有啊 post=4 的就啊他参与过的
但是这句:
select distinct PostComment.PostID
from PostComment JOIN
     CommentReply on PostComment.UserID=CommentReply.UserID
where PostComment.UserID=2  or
      CommentReply.UserID=2
却没有查出来
只有本站会员才能查看附件,请 登录


这是为什么啊?急啊  求解

1