2010-09-11 30 views

回答

2
Post.find :all, :conditions => ['type IN (?)', ['Post', 'ChildPost']] 

或者:

values = ['Post', 'ChildPost'] 
Post.find :all, :conditions => ['type IN (?)', values] 

这应该生成以下SQL:

SELECT * FROM `posts` WHERE `type` IN ('Post', 'ChildPost'); 
+0

真棒,谢谢!如何在只是原始的SQL? – 2010-09-11 21:46:59

+0

没问题:)我编辑与预期的RAW SQL的答案。 – aularon 2010-09-11 21:52:29

相关问题