我有表" user_following"(用户遵循的所有潜行客户)user_id(int(10)) and follow_sub(varchar(30))
" user_likes"(用户的所有喜欢)表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)
我有两种订购帖子的方法:
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;";
我想结合两个连接 - 用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";
我怎样才能让它发挥作用?
答案 0 :(得分:2)
它给出了一个布尔值,因为你使用的mysql或mysqli的任何风格都是返回false而不是语句对象,因为你有无效的sql
FROM userpost.*
应该是
FROM userpost