# Query & compose an array

**URL:** <https://www.ruby-forum.com/t/query-compose-an-array/152131>\
**Category:** Rails\
**Created:** [October 30, 2008, 12:28pm UTC](https://www.ruby-forum.com/t/query-compose-an-array/152131 "2008-10-30T12:28:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [October 30, 2008, 12:28pm UTC](https://www.ruby-forum.com/t/query-compose-an-array/152131/1 "2008-10-30T12:28:51Z")

</div>

Hi there,

What’s the correct & most efficient way to compose the following array?

I have:

# Existing tables:

- users (:id)
- user\_languages (:id, :user\_id, :language\_id)
- languages (:id, :name)

# Existing array:

@user\_languages

# Wanted array: (for a specific user)

“@languages” = Languages.find(:all) - (“Languages” whose “:ids” can be  
found as “:language\_ids” in the existing array “@user\_languages”)

Thanks a lot for your help!  
Tom
