-2

我希望此代码仅显示$user_id的朋友的结果,但我想显示来自朋友和$user_id的结果

SELECT *
FROM
  activity,
  friends
WHERE
  friends.user_id='$user_id'
  and activity.activity_user=friends.fr_id
ORDER BY activity.id DESC
LIMIT 10
4

1 回答 1

0

使用加入

SELECT
  t1.*
FROM
  activity as t1
  join friends on t1.activity_user=friends.fr_id
WHERE
  friends.user_id='$user_id'
ORDER BY t1.id DESC
LIMIT 10
于 2013-08-17T07:03:36.397 回答