我有表user_id(int(10)) and follow_sub(varchar(30))
排序合併聯接
「user_likes」(用戶的所有喜歡)表「user_following」(所有用戶按照潛艇)與user_id(varchar(15)) and post_sub(varchar(15))
和「user_post」與user_id(int(10)) post_txt(text) sub_id(varchar(30) parallel to follow_sub) post_unix_time(float)
我有2種方式來訂購的帖子:
1)通過最新的職位潛艇,用戶如下:
$result11="SELECT * FROM user_post
INNER JOIN users_following ON user_post.sub_id=users_following.follow_sub
WHERE users_following.user_id='$userid'
ORDER BY user_post.post_id DESC";
2)通過算法計算每篇文章的喜歡,但所有的SUBS(即使用戶不跟隨他們):
$result11="SELECT user_post.*, (LOG10(ABS(COUNT(user_likes.post_id)) + 1) * SIGN(COUNT(user_likes.post_id)))/user_post.post_unix_time AS like_count
FROM user_post LEFT JOIN user_likes
ON user_post.post_id = user_likes.post_id
GROUP BY user_post.post_id
ORDER BY like_count desc;";
我想joins-兩者結合起來用LIKES ALGORITHM將帖子呈現給他所關注的潛在用戶。
這是我試圖做到這一點,但它告訴我錯誤 - mysql_num_rows() expects parameter 1 to be resource, boolean given in
:
$result11="SELECT user_post.*, (LOG10(ABS(COUNT(user_likes.post_id)) + 1) * SIGN(COUNT(user_likes.post_id)))/user_post.post_unix_time AS like_count
FROM user_post.*
LEFT JOIN user_likes ON user_post.post_id = user_likes.post_id
INNER JOIN users_following ON user_post.sub_id=users_following.follow_sub
WHERE users_following.user_id='$userid'
GROUP BY user_post.post_id
ORDER BY like_count DESC";
我怎樣才能使它發揮作用?
當然FROM FROM userpost。*應該是FROM userpost –