MT tip - Listing 'uncategorized' entries

I've occasionally seen the question asked of how to list uncategorized entries (entries not assigned to any category) in Movable Type. Movable Type does not really offer any way to do this, so I played a bit with Brad Choate's SQL plugin and came up with the following:

<MTSQLEntries query="SELECT entry_id
   FROM mt_entry LEFT JOIN mt_placement
   ON entry_id = placement_entry_id
   WHERE entry_blog_id = &lt;MTBlogID&gt;
      AND entry_status = 2
      AND placement_entry_id IS NULL
   ORDER BY entry_created_on DESC
   LIMIT 10">
   <$MTEntryDate format="%m/%d/%Y"$> <a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><br />
</MTSQLEntries>

This will list the last 10 uncategorized entries 1) only in the current weblog, 2) only published entries, and 3) in descending entry date order. The query can be modified in a number of ways. For example, to list all uncategorized entries, remove 'LIMIT 10' from the end of the query.

The above code is intended to be placed in an Index template, with the <MTSQLEntries> and </MTSQLEntries> tags replacing <MTEntries> and </MTEntries>. It would be meaningless to use this code in a Category or Individual Archive template. To use in a Date-Based Archive template, date comparisons need to be added to the query in order for it work properly:

<MTSQLEntries query="SELECT entry_id
   FROM mt_entry LEFT JOIN mt_placement
   ON entry_id = placement_entry_id
   WHERE entry_blog_id = &lt;MTBlogID&gt;
      AND entry_status = 2
      AND placement_entry_id IS NULL
      AND entry_created_on &gt;= '&lt;MTArchiveDate format=&quot;%Y-%m-%d&quot;&gt;'
      AND entry_created_on &lt; DATE_ADD('&lt;MTArchiveDateEnd format=&quot;%Y-%m-%d&quot;&gt;', INTERVAL 1 DAY)
   ORDER BY entry_created_on DESC"
   default="&lt;div class=&quot;blogbody&quot;&gt;No entries&lt;/div&gt;">
   <$MTEntryDate format="%m/%d/%Y"$> <a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><br />
</MTSQLEntries>

One drawback to using this code in a Date-Based Archive: Empty archive pages will be generated for archive periods that have entries but no uncategorized entries. As far as I know, there is no workaround for this.