<p>FeedMe plugin imports categories, so you could create an xml template file that outputs your entries and their checkbox values(separated by commas), then use FeedMe to import that file back in and map those checkboxes to your categories. They just have to match spelling, otherwise FeedMe will create a new category</p>

<p><a href="https://github.com/engram-design/FeedMe" rel="nofollow">FeedMe</a></p>

<p>Something like:</p>

<pre><code>&lt;xml&gt;
  &lt;blog&gt;
    {% for entry in entries %}
      &lt;entry&gt;
        &lt;title&gt;{{ entry.title }}&lt;/title&gt;{# required for import #}
        &lt;category&gt;&lt;![CDATA[{% for option in entry.checkboxFieldHandle %}{{ option }}, {% endfor %}]]&gt;&lt;/category&gt;
      &lt;/entry&gt;
    {% endfor %}
  &lt;/blog&gt;
 &lt;/xml&gt;
</code></pre>

CC BY-SA 3.0
2016-08-25T23:04:03.327Z
ok this doesn't seem to work. I made the xml feed and can access it in the browser. Feed me can pick it up, but when I run the import, the new categories field remains unchanged even when the log says it's successfully updated
ChaiTea
CC BY-SA 3.0
2016-08-26T14:01:15.810Z
Did you map it to your categories field in FeedMe? A couple of things that slipped me up when I was doing it...1. make sure devMode is off. 2. in the settings of FeedMe, make sure "Primary element" is set(in my case "entry"). Then maybe check your "Import Strategy" is set to Add and Update existing.
AbbeyDesign
CC BY-SA 3.0
2016-09-15T17:58:14.650Z
Ok finally got this working, a big gotcha is that when selecting import options, I had to choose import title field to the title field, otherwise feed me doesn't know which entry is related to which, and just updates one entry over and over again
ChaiTea
CC BY-SA 3.0
2016-08-25T00:12:33.243Z
2016-08-25T00:12:33.243Z
AbbeyDesign
<p>In a project I have a checkbox field called <code>gradeLevels</code> with 3 options (k-5,6-8, and 9-12). </p>

<p>Due to design changes, I need to convert this field into a category field. I've made a new category with the same names (k-5,6-8, and 9-12), but I already have data in all of the entries that uses the old checkbox field.</p>

<p>I poked around in mysql and listed all the columns in craft_fields table, but I don't see the newly created categories field in the list, or any categories/entries field for that matter. I'm guessing associations are stored in a different manner?</p>

<p>Is there a possible way using mysql to map all the string values in the check box fields into the corresponding category in the categories field?</p>

CC BY-SA 3.0
2016-08-24T22:41:57.760Z
Not a full answer, but category field data (along with all other relational field data - assets, users, entries, etc.) is stored in the `craft_relations` table.
Brad Bell
CC BY-SA 3.0
2016-08-24T23:00:18.813Z
As Brad mentioned, Categories are stored much differently than checkboxes. Doing this purely through SQL queries is risky. How many Entries are you dealing with in total?
Lindsey D
CC BY-SA 3.0
2016-08-24T23:29:54.750Z
FeedMe plugin imports categories, so you could create an xml template file that outputs your entries and their checkbox values(separated by commas), then use FeedMe to import that file in and map that to your cats. They just have to have the same name or FeedMe will create new ones. Just back up your db! I'm only commenting because I imported categories once on a site and have no real experience trying to do what you want.
AbbeyDesign
CC BY-SA 3.0
2016-08-24T23:34:15.517Z
@Lindsey roughly 500 entries. It's okay if I break it during testing because I have many backup copies of the DB. Looks like the checkbox field type is stored as varchar(255)
ChaiTea
CC BY-SA 3.0
2016-08-24T23:46:05.727Z
@AbbeyDesign: I was thinking something similar... use Feed Me to create a sort of self-referential loop. I think it's a great idea, you should add it as an official answer!
Lindsey D
<categories><database><fieldtypes><mysql>
map values from checkbox field into category field using SQL
# map values from checkbox field into category field using SQL

(Asked by: username_0 on 2016-08-24)

In a project I have a checkbox field called `gradeLevels` with 3 options (k-5,6-8, and 9-12).

Due to design changes, I need to convert this field into a category field. I've made a new category with the same names (k-5,6-8, and 9-12), but I already have data in all of the entries that uses the old checkbox field.

I poked around in mysql and listed all the columns in craft\_fields table, but I don't see the newly created categories field in the list, or any categories/entries field for that matter. I'm guessing associations are stored in a different manner?

Is there a possible way using mysql to map all the string values in the check box fields into the corresponding category in the categories field?

**Tags:** categories, database, fieldtypes, mysql
> **Comments:**
> **username_1**: Not a full answer, but category field data (along with all other relational field data - assets, users, entries, etc.) is stored in the `craft_relations` table.  
> **username_2**: As Brad mentioned, Categories are stored much differently than checkboxes. Doing this purely through SQL queries is risky. How many Entries are you dealing with in total?  
> **username_3**: FeedMe plugin imports categories, so you could create an xml template file that outputs your entries and their checkbox values(separated by commas), then use FeedMe to import that file in and map that to your cats. They just have to have the same name or FeedMe will create new ones. Just back up your db! I'm only commenting because I imported categories once on a site and have no real experience trying to do what you want.  
> **username_0**: @Lindsey roughly 500 entries. It's okay if I break it during testing because I have many backup copies of the DB. Looks like the checkbox field type is stored as varchar(255)  
> **username_2**: @AbbeyDesign: I was thinking something similar... use Feed Me to create a sort of self-referential loop. I think it's a great idea, you should add it as an official answer!  

---

## 1 answers

### Answer by username_3 on 2016-08-25. Score: 3 | Accepted answer

FeedMe plugin imports categories, so you could create an xml template file that outputs your entries and their checkbox values(separated by commas), then use FeedMe to import that file back in and map those checkboxes to your categories. They just have to match spelling, otherwise FeedMe will create a new category
FeedMe
Something like:

  
    {% for entry in entries %}
      
        {{ entry.title }}{# required for import #}
        {% for option in entry.checkboxFieldHandle %}{{ option }}, {% endfor %}
      
    {% endfor %}

> **Comments:**
> **username_0**: ok this doesn't seem to work. I made the xml feed and can access it in the browser. Feed me can pick it up, but when I run the import, the new categories field remains unchanged even when the log says it's successfully updated  
> **username_3**: Did you map it to your categories field in FeedMe? A couple of things that slipped me up when I was doing it...1. make sure devMode is off. 2. in the settings of FeedMe, make sure "Primary element" is set(in my case "entry"). Then maybe check your "Import Strategy" is set to Add and Update existing.  
> **username_0**: Ok finally got this working, a big gotcha is that when selecting import options, I had to choose import title field to the title field, otherwise feed me doesn't know which entry is related to which, and just updates one entry over and over again  

---

