Results 1 to 1 of 1
Apr 10, 2006, 13:14 #1
- Join Date
- Nov 2001
- 0 Post(s)
- 0 Thread(s)
Help with finding records by foreign key in a many to many relationship
I have business listings that go into classifications through a shortcuts table.
:has_many classifications, :through => :shortcuts
Now let's say I want to find all businesses that have shortcuts into the classification with id 3.
SELECT * FROM businesses INNER JOIN shortcuts ON businesses.id = shortcuts.business_id WHERE shortcuts.classification_id = 3