 <p>You can express your query as:</p> <pre><code>SELECT IdPerson FROM Person p JOIN CustomFieldXPerson cfxp on cfxp.IdPerson = p.IdPerson JOIN Filter f on f.IdField = cfxp.IdField AND (f.Criteria = '=' and f.Value = cfxp.Value or f.Criteria = '&lt;' and f.Value &lt; cfxp.Value or f.Criteria = '&lt;=' and f.Value &lt;= cfxp.Value or f.Criteria = '&gt;' and f.Value &gt; cfxp.Value or f.Criteria = '&gt;=' and f.Value &gt;= cfxp.Value ) WHERE f.GroupId = X ; </code></pre> <p>EDIT:</p> <p>If you want to get persons that match all filters, just use <code>group by</code>:</p> <pre><code>SELECT IdPerson FROM Person p JOIN CustomFieldXPerson cfxp on cfxp.IdPerson = p.IdPerson LEFT JOIN Filter f on f.IdField = cfxp.IdField AND (f.Criteria = '=' and f.Value = cfxp.Value or f.Criteria = '&lt;' and f.Value &lt; cfxp.Value or f.Criteria = '&lt;=' and f.Value &lt;= cfxp.Value or f.Criteria = '&gt;' and f.Value &gt; cfxp.Value or f.Criteria = '&gt;=' and f.Value &gt;= cfxp.Value ) AND f.GroupId = X GROUP BY idPerson HAVING COUNT(f.IdField) = COUNT(*) OR COUNT(f.IdField) = 0; </code></pre> <p>In other words, all the filters that match the person, in the group, match. The additional condition in the <code>HAVING</code> clause is in case the filter group has no filters.</p>