If you're working with a site with a lot of nodes, especially nodes that have been migrated out of another CMS or blogging tool, you'll probably find yourself wondering which nodes are floating around without any taxonomy terms, so that you can go back and make sure they're duly categorized.
Getting a raw list of node ID's and titles is simple with the following SQL query, which you can execute from the MySQL command line client, or PHPMyAdmin (which your web host's admin panel probably provides):
SELECT nid, title FROM `node` n WHERE n.nid NOT IN (SELECT DISTINCT nid FROM `term_node`);
From there you can just go to your browser and start plugging in edit urls: `http://mysite.com/node/123/edit`, `http://mysite.com/node/456/edit`, et cetera.
If you have a large number of uncategorized nodes, it may be worth writing a module to find and/or categorize them automatically.


Pass it on...
thanks andy! my developer was having a similar problem migrating one of my sites to drupal...I'll point him to your article and see if it helps... thanks a lot for selflessly sharing your knowledge!
Why you can't just delete
Why you can't just delete these nodes like this:
DELETE FROM `node` WHERE n.nid NOT IN (SELECT DISTINCT nid FROM `term_node`)
?
thanks for the node-finding
thanks for the node-finding trick. I'm sure theres a way to write this into a quick push-button style plugin, to keep track of drupal sites with thousands of nodes.
Uncategorized Nodes Trick
This works really well. Actually i tried on my site CHETAN
and was amazed by the results. Thanks for sharing.
It's easier to do it with
It's easier to do it with Views module.
Add a filter "Category: ID" and choose "is empty (Null)" and you have them all listed.
Then you can add bulk categorise them with "views bulk operations" module and you're home.
Nodes
In communication networks, a node (Latin nodus, ‘knot’) is a connection point, either a redistribution point or a communication endpoint (some terminal equipment). The definition of a node depends on the network and protocol layer referred to. A physical network node is an active electronic device that is attached to a network, ccnp exams, and is capable of sending, receiving, or forwarding information over a communications channel. A passive distribution point such as a distribution frame is consequently not a node.
Thanks for this trick. It
Thanks for this trick.
It could be nice to have such thing realized as module.
Alternate result: SELECT
Alternate result:
SELECT n.nid FROM node n LEFT JOIN term_node tn ON n.nid = tn.nid GROUP BY n.nid HAVING count(tn.tid) = 0;
pp
You're right, thanks!
I've updated the query accordingly.
Since nodes may be
Since nodes may be categorized with more than one term, the inner select will return duplicates: you probably want to "SELECT DISTINCT nid FROM term_node".
Post new comment