我有以下查找帖子。
@posts = Post.find(:all,
:select => "DISTINCT *",
:include => [:user, {:track => :artist}],
:conditions => ["user_id IN (?) AND NOT track_id = ?", users, @track.id],
:group => "track_id",
:order => 'id desc',
:limit => '5')
我想添加子选择
(SELECT COUNT(*) FROM posts P2
WHERE P2.user_id = P1.user_id AND P2.id > P1.id AND P2.track_id <> 34)
<= 1
在我的条件条款中,限制每个用户的帖子数量。
如何将别名 P1 设置为“初始”帖子表?
使用导轨 2.3.11