2011-08-31 56 views
0

我有如下sphinx的屬性。思維獅身人面像sql_range_query錯誤索引

meeting_feedback_count = <<-SQL 
    SELECT meetings.* 
    FROM  meetings 
    JOIN  member_meetings mm 
    ON  mm.meeting_id = meetings.id 
    JOIN  meeting_feedbacks mf 
    ON  mf.member_meeting_id = mm.id 
    GROUP BY meetings.id 
SQL 

has meeting_feedback_count, :as => :has_feedback, :type => :boolean 

我在mysql控制檯執行sql,它似乎工作正常。但我得到的錯誤。有沒有辦法解決,。

sql_range_query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*)  

回答

1

由於您將完整的SQL查詢插入到另一個SQL查詢中,因此發生此錯誤。您只需要爲正在添加的字段或屬性使用適當的列。

如果模型這個指數是爲會議,那麼你可能想是這樣的:

"COUNT(meeting_feedbacks.id) > 0", :as => :has_feedback, :type => :boolean 
join feedbacks 

join方法力量加入對你可能指的是SQL片段的關聯。