Hi, Can't your sql be :
select * from decks d inner join cards c1 on c1.deck_id=d.id where c1.rank = 'Ace' and c1.rank = 'King'; On Tue, Apr 27, 2010 at 18:40, Ben Woodcroft <[email protected]> wrote: > Sharagoz wrote: > > @decks_with_aces_and_kings = Deck.all(:joins => :cards, :conditions => > > "cards.rank = 'Ace' OR cards.rank = 'King'") > > Looks good, except it seems my question wasn't clear (even to me > re-reading it). I want decks that have kings and aces, so an OR isn't > what I'm looking for. Any ideas then? > > SQL would be something like > --------------------------- > select * from decks d > inner join cards c1 on c1.deck_id=d.id > inner join cards c2 on c2.deck_id=d.id > where > c1.rank = 'Ace' and > c2.rank = 'King'; > ---------------------------- > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<rubyonrails-talk%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- Thanks & Regards, Dhruva Sagar. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

