# What is best way to get all records from

**URL:** <https://www.ruby-forum.com/t/what-is-best-way-to-get-all-records-from/121130>\
**Category:** Rails\
**Created:** [November 24, 2007, 6:25am UTC](https://www.ruby-forum.com/t/what-is-best-way-to-get-all-records-from/121130 "2007-11-24T06:25:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike343](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike343](https://www.ruby-forum.com/u/mike343)\
**Post date:** [November 24, 2007, 6:25am UTC](https://www.ruby-forum.com/t/what-is-best-way-to-get-all-records-from/121130/1 "2007-11-24T06:25:03Z")

</div>

Hi,

Any tips on how can I get all rows given the following example?

Table:  
Instruments (contains instruments I own)

Records:  
Piano  
Guitar  
Keyboard  
Flute  
Violen

Table:  
Songs (a library of all my songs)

Records:  
Paradise City (id 1)  
Back In Black (id 2)

Table:  
Instruments\_In\_Song (rows for each instrument in each song from above  
table)  
Guitar (song\_id 1)  
Keyboard (song\_id 1)  
Guitar (song\_id 2)  
Drums (song\_id 2)

Forget about the accuracy of the actual example. What I want is to find  
all songs that have instruments that I own. In the example above, the  
query would include Paradise City since I have a guitar and a keyboard,  
but would omit Back in Black since I have a guitar, but don’t have a  
drum set.

Any pointers with ActiveRecord or general SQL would be helpful.

Thank you,

Michael
