gpt4 book ai didi

php - 按组合连接排序

转载 作者:行者123 更新时间:2023-11-29 06:14:27 27 4
gpt4 key购买 nike

我有表“user_following”(用户关注的所有订阅者),其中包含 user_id(int(10)) 和 follow_sub(varchar(30))

“user_likes”(用户的所有点赞)表,包含 user_id(varchar(15)) 和 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) 通过算法计算每篇文章的点赞数,但包含所有订阅者(即使用户没有关注他们):

        $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";

我怎样才能让它发挥作用?

最佳答案

它给出一个 bool 值,因为您使用的任何类型的 mysql 或 mysqli 都返回 false 而不是一个语句对象,因为您有无效的 sql

来自用户帖子。*

应该是

来自用户帖子

关于php - 按组合连接排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36644252/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com