【发布时间】:2014-04-11 11:14:07
【问题描述】:
我有三个查询给了我单独正确的结果,但我的要求是我只需要一个查询的所有结果,所以我应该如何继续?
select * from user_post_like
inner join user_post on user_post_like.postID = user_post.postID
inner join Users on Users.userID=user_post_like.userID
where (user_post.poster='$uid' AND user_post_like.userID!='$uid')
ORDER BY likeID DESC;
select * from user_post_comment
inner join user_post on user_post_comment.postID = user_post.postID
inner join Users on Users.userID=user_post_comment.commenter
where (user_post.poster='$uid' AND user_post_comment.commenter!='$uid')
ORDER BY commentID DESC;
select * from user_post_share
inner join user_post on user_post_share.postID = user_post.postID
inner join Users on Users.userID=user_post_share.Share_user_id
where (user_post.poster='$uid' AND user_post_share.Share_user_id!='$uid')
ORDER BY shareID DESC;
【问题讨论】:
-
我看到了一个与 user_post 的共同加入...也许这就是答案
-
@RobertRozas 可以吗,请提供查询?
-
@Datta 很好的评论。 Stack Overflow 的精髓。
-
根据给出的信息,这三个查询似乎极其无关
-
@Ic 我有三个表,例如,comment,share,其中包含有关表 post 中的帖子的数据以及表 user 中的所有用户详细信息,因此我有三个单个查询工作正常,但是如何组合所有结果