视频表有列votes_count,我需要找到下一个热门视频。我写了类似下面的东西,但它没有帮助。任何帮助将不胜感激。
@video = Video.find(1)
@next_video = Video.where("votes_count >= ? AND id != ?", @video.votes_count, @video.id).order("votes_count").first
答案 0 :(得分:0)
@video = Video.find(1)
@next_video = Video.where("id != ?", @video.id).order("votes_count DESC").first
答案 1 :(得分:0)
@video = Video.find(1)
@next_video = Video.where("votes_count > ? OR (votes_count = ? AND id > ?)", @video.votes_count, @video.votes_count, @video.id).order("votes_count").order("id").first