MYSQL,按喜欢排序
我有 2 个表“主题”和“帖子”,我想搜索我的帖子并按最匹配的主题排序。
现在我有这个:
SELECT Threads.*
FROM Posts
INNER JOIN Threads ON Posts.ThreadID=Threads.ThreadID
WHERE Posts.Content LIKE '%" . $search . "%'
OR Posts.User LIKE '%" . $search ."%'
I have 2 tables Thread and Posts, i would like to search my posts and order by thread with most matches.
Right now i have this:
SELECT Threads.*
FROM Posts
INNER JOIN Threads ON Posts.ThreadID=Threads.ThreadID
WHERE Posts.Content LIKE '%" . $search . "%'
OR Posts.User LIKE '%" . $search ."%'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以添加一个联接来计算每个线程的帖子数。由于您没有从帖子中选择任何列,因此这是您需要的唯一联接。
You could add a join to calculate the number of posts per thread. Since you're not selecting any columns from Posts, that's the only join you'll need.