Display all related entries in a table I'm building a site that contains a listing of products and distributors. I have a channel for each, and each entry in the distributors channel contains a relationship field to tie it to any number of entries in the products channel. There are about 20 entries in each channel.

I need to set up a page with a table that includes all of the products across the top, and all of the distributors in the left column, with a check box in each cell where there is a relationship between the two.

I know how to just use standard related entries tags to output the distributors and list out the related products for each, but is there a way get it into the table format, without a ridiculous number of queries?
Let me show you the quickest solution I could think of. 
If you put it in {% cache %} tags, you should be fine. You could also create a little plugin that returns the required data from one big-ass query, if you're into building plugins. If you have any plugin experience, then building a plugin is what I would do.

{% set distributors = craft.entries.section('distributors').limit(null) %}
{% set allRelatedProducts = craft.entries.section('products').relatedTo(distributors).limit(null) %}

&lt;table&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th&gt;Distributor&lt;/th&gt;
            {% for product in allRelatedProducts %}
                &lt;th&gt;{{ product.title }}&lt;/th&gt;
            {% endfor %}
        &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
        {% for distributor in distributors %}
            {# Get ids for all products related to distributor #}
            {% set productsForDistributor = craft.entries.section('products').relatedTo(distributor).limit(null).ids() %}
            &lt;tr&gt;
                &lt;td&gt;{{ distributor.title }}&lt;/td&gt;
                {% for product in allRelatedProducts %}
                    {# 
                     # Check if product ID is in array containing this distributor's products
                     # and display value accordingly
                     #}
                    &lt;td&gt;{{ product.id in productsForDistributor ? 'yes' : 'no' }}&lt;/td&gt;
                {% endfor %}
            &lt;/tr&gt;
       {% endfor %}
    &lt;/tbody&gt;
&lt;/table&gt;