I had 500 or so entries I needed to define a default category for. I did about 100 with the entry bulk change GUI but even that was abysmally slow. I figured this had to be stored in a table somewhere, so I started poking around the database to see what I would find. mt_entry indeed has a "category_id" , but it curiously turned out be NULL for every entry, even ones with a single, default category. I pried around for about an hour to no avail until I was saved by Google leading me to a post by Mike Kruckenberg on his blog about Movable Type categories. Turns out that MT abandoned that field a while ago in favor of a linking table for mt_entry and mt_category called "mt_placement" (like that name was obvious) which allowed for primary and secondary categories. So after a bit of learning, translating my Oracle SQL to the MySQL dialect, I came up with the following one-stop query to set a default category (17, determined by looking through mt_category) for just one blog's entries that didn't already have a category assignment. In case it saves anyone the hour or two of hair-pulling, here it is (but be sure to change the blog ID and category ID as appropriate for you):
INSERT INTO mt_placement (placement_entry_id, placement_blog_id, placement_category_id, placement_is_primary)
SELECT e.entry_id, 1, 17, 1
FROM mt_placement p RIGHT OUTER JOIN mt_entry e ON p.placement_entry_id = e.entry_id
WHERE e.entry_blog_id = 1
AND p.placement_is_primary IS NULL;
Note that this does not catch the screwball case where an entry has secondary categories but no primary category, and would still post a primary category for the entry. (I'm not sure if the MT software actually would allow such a condition to occur, however.)
