Joining tables

Hi
I have 3 tables as

  1. user_groups
    id | contact_id | group_id | group_user_type_id
  2. contact
    id | name_first | name_last |
    3)contact_email_addresses
    contact_id | contact_email_address_type_id | emailaddress

Now I have group_id sa for example 68
What I want is from contact_email_addresses table get all the
emailaddress with contact_email_address_type_id=2 for the contacts with
this group_id under the condition in the user_groups table
group_user_type_id=2
How can I do this?

hanks in advance
Sijo

ContactEmailAddresses.find( :all, :conditions =>
‘contact_email_address_type_id = 2 and group_user_type_id = 2’
:include =>
‘user_groups’
)

Something to that effect should work… however it depends how you
have your relationships setup… this would work too…
contact_type = ContactEmailAddressType.find(2)
contact_type.contact_email_addresses.find(:all, :coditions =>
‘group_user_type_id = 2’, :include => ‘user_groups’ )

Hi
thanks for your reply
Sijo