# Filtering For A Result - Advice

**URL:** <https://www.ruby-forum.com/t/filtering-for-a-result-advice/140753>\
**Category:** Rails\
**Created:** [June 18, 2008, 9:20am UTC](https://www.ruby-forum.com/t/filtering-for-a-result-advice/140753 "2008-06-18T09:20:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexmic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@alexmic](https://www.ruby-forum.com/u/alexmic)\
**Post date:** [June 18, 2008, 9:20am UTC](https://www.ruby-forum.com/t/filtering-for-a-result-advice/140753/1 "2008-06-18T09:20:34Z")

</div>

I’m creating an advanced search form and I have to filter the results  
based on whether particular rows exist in other tables.

For example:  
Project has\_many ResearchProjects

Project.find(:all,  
:joins =\> “INNER JOIN research\_projects\_vw ON  
research\_projects\_vw.fin\_project\_id = project\_totals\_vw.fin\_project\_id”,  
:conditions =\> [“research\_projects\_vw.funding\_type\_code in  
(?)”, ns[‘funding\_types’].split(’,’)])

Is there a good way of preventing getting a Cartesian product using this  
join, or should i just be providing an option like :select =\> ‘distinct  
fielda, distinct fieldb’ etc
