加入bb_user表兩次,別名爲一個(用戶)和b(用於跟隨者)。
select f.USER_ID, a.user_firstname, a.user_email,
f.FOLLOW_ID, b.user_firstname as follower_firstname, b.user_email as follower_email
from bb_follow f, bb_user a, bb_user b
where a.user_id = f.User_Id
and b.user_id = f.Follow_Id
and f.Active_Status=1
或ANSI連接:
select f.USER_ID, a.user_firstname, a.user_email,
f.FOLLOW_ID, b.user_firstname as follower_firstname, b.user_email as follower_email
from bb_follow f
join bb_user a on a.user_id = f.User_Id
join bb_user b on b.user_id = f.Follow_Id
where f.Active_Status=1
那你試試? –
我現在嘗試從相同的用戶表我必須添加追隨者的名字和電子郵件ID –
按照表(用戶名,followId,IsActive)用戶表(用戶名,名,emailid) - 謝謝 –