<p>Craft saves all the table's data serialized to a single cell in the database, so there's not really a good way to set query conditions to match something in a table field.</p>

<p>What you could do is to use Andre Elvan's brand new plugin <a href="https://github.com/aelvan/Preparse-Field-Craft" rel="nofollow">Preparse Field</a>. With that you would add a new field to you entry type that does some predefined Twig logic on every entry save. So you could get that table cell's data you are interested in and write it to its own field that you could then use as a field parameter in your criteria model.</p>

<p>Another way, and this is the approach I would actually recommend, is to refactor the whole setup and use a separate channel to hold each table row as its own entry (without URL) and than have an Entries field to relate those to your week / event entry.</p>

<p>The third solution is a variant of the second one, but to use a Matrix field (or a SuperTable) instead of a separate channel. You would need to set up the query with Yi query builder from a custom little plugin. Let me know if you're interested in this solution and I can assist you in setting this up.</p>

CC BY-SA 4.0
2020-06-15T20:43:54.470Z
Your second solution turned out to be the best in my case. Thanks for taking the time to answer.
Mosswalker
CC BY-SA 3.0
2015-09-05T18:28:31.303Z
2015-09-05T18:28:31.303Z
carlcs
<p>I'm trying to query up some entries based on a value inside an editable table.</p>

<p>Here's two pictures on how it's set up:<br>
<a href="https://i.sstatic.net/UW9yV.png" rel="nofollow noreferrer">https://i.sstatic.net/UW9yV.png</a><br>
<a href="https://i.sstatic.net/P4Gtc.png" rel="nofollow noreferrer">https://i.sstatic.net/P4Gtc.png</a></p>

<p>My current template (stripped) looks like this:</p>

<pre><code>{% set courses = craft.entries({
    section: 'course',
    search: 'participants:31'
}) %}


&lt;section class="user-dashboard"&gt;

    &lt;h1 class="user-dashboard__upcoming-title"&gt;
        Upcomming courses
    &lt;/h1&gt;

    {% for course in courses %}
        {{course.title}} &lt;br&gt;
    {% endfor %}

&lt;/section&gt;
</code></pre>

<p>I've tried a couple of other parameters to the query, such as</p>

<pre><code>participants['col4']: '31'
</code></pre>

<p>and </p>

<pre><code>participants: '["col4"]:31'
</code></pre>

<p>but almost no dice. I get a result, but it matches with all the other values as well. I only want it to match with "userID" column, aka col4.</p>

<p>For example, I get the same results if I try '1' instead of '31'.</p>

<templating><entries><table-field>
How do I query for entries, based on a value inside a table?
# How do I query for entries, based on a value inside a table?

(Asked by: username_0 on 2015-09-05)

I'm trying to query up some entries based on a value inside an editable table.
Here's two pictures on how it's set up:
https://i.sstatic.net/UW9yV.png
https://i.sstatic.net/P4Gtc.png
My current template (stripped) looks like this:
{% set courses = craft.entries({
    section: 'course',
    search: 'participants:31'
}) %}




    
        Upcomming courses
    

    {% for course in courses %}
        {{course.title}} 
    {% endfor %}



I've tried a couple of other parameters to the query, such as
participants['col4']: '31'

and 
participants: '["col4"]:31'

but almost no dice. I get a result, but it matches with all the other values as well. I only want it to match with "userID" column, aka col4.
For example, I get the same results if I try '1' instead of '31'.

**Tags:** templating, entries, table-field


---

## 1 answers

### Answer by username_1 on 2015-09-05. Score: 3

Craft saves all the table's data serialized to a single cell in the database, so there's not really a good way to set query conditions to match something in a table field.

What you could do is to use Andre Elvan's brand new plugin [Preparse Field](https://github.com/aelvan/Preparse-Field-Craft). With that you would add a new field to you entry type that does some predefined Twig logic on every entry save. So you could get that table cell's data you are interested in and write it to its own field that you could then use as a field parameter in your criteria model.

Another way, and this is the approach I would actually recommend, is to refactor the whole setup and use a separate channel to hold each table row as its own entry (without URL) and than have an Entries field to relate those to your week / event entry.

The third solution is a variant of the second one, but to use a Matrix field (or a SuperTable) instead of a separate channel. You would need to set up the query with Yi query builder from a custom little plugin. Let me know if you're interested in this solution and I can assist you in setting this up.

> **Comments:**
> **username_2**: Your second solution turned out to be the best in my case. Thanks for taking the time to answer.  

---

