0

我有这样的 UserComments 表:

1 | Frank | hello world
2 | Jane | Hi there
3 | Frank | this is my comments
4 | Frank | I think I need some sleep
5 | Jason | I need to buy new MacBook
6 | Jane | Please invite my new Blackberry PIN

另一方面,我有 FriendList 表包含:

1 | Jason
2 | Jane

假设我的朋友 ID 总是介于 1 和 5 之间。

而且由于弗兰克不是我的朋友,我无法看到他的评论。如何组合这样的表(ORDER BY UserComments.ID DESC):

1 | Jane | Please invite my new Blackberry PIN
2 | Jason | I need to buy new MacBook
3 | Jane | Hi there

谢谢。

4

2 回答 2

1

试试这个:

    SELECT A.ID, B.UserName, B.Comment 
      FROM FriendList A
INNER JOIN UserComments B ON A.ID = B.ID
  ORDER BY A.ID DESC
于 2012-06-17T08:15:59.120 回答
1

试试这个::

Select 
* 
from 
user_comments inner join friend_List on (join criteria)
where user_Id = ? order by user_comments.id desc
于 2012-06-17T08:18:24.537 回答