Need help on AR query

Hi,

I have a problem with AR query, i have 3 table that is link ( Product, item, item_attribute )

Product.item_id link with item.product_id

item.item_id link with item_attribute.item_attribute_id.

The item_attribute will have different type of attribute for the item, the structure is like below

Product table

id item_id

10 5

item table

item_id product_id

1 5

item_attribute table

Id type value

1 class Assasin

1 race Human

1 skill Hide

2 class Knight

2 race Human

2 skill Block

i need to do filter base one item_attribute and return in a 1 row data for each product, how do i write for the AR?