Custom query to db

Hi all,
I have problem regarding querying database in rails database.
Senerio:
There are 2 models ‘user’ and ‘interests’
Association between them is has_and_belongs_to_many

Now If I want to list common interests between two users. How do I query
db.
I think, we have to write custom plsql statement.
Can I know your thoughts.

Thank you,
Aashish

On Sun, Apr 8, 2012 at 3:34 AM, Aashish K. [email protected]
wrote:

There are 2 models ‘user’ and ‘interests’
Association between them is has_and_belongs_to_many

Now If I want to list common interests between two users. How do I query
db.
I think, we have to write custom plsql statement.

?! user1.interests and user2.interests are just arrays.

You don’t need a SQL statement to figure out the intersection of two
arrays. :slight_smile:


Hassan S. ------------------------ [email protected]

twitter: @hassan