Finding all nodes not referenced by a menu entry or another node In the course of creating the content for a site, we've ended up with orphaned content nodes that are not linked to from anywhere. I'd like to find and examine these. Surprisingly, I can't find a module for this.

Tiny hypothetical example: I'm building a brochureware site. Someone wrote a "Contact" page, someone else wrote an "About Us", and someone else wrote "Directions". The person writing "Directions" forgot to put it in a menu link or add a link from "About Us" to "Directions". So "Directions" is orphaned: there are no links to it. I'd like to find all such nodes so I can figure out what to do with them.
I needed this for a clients request, so i decided to try and do it without any additional modules, and push my MySQL a bit. This is what i ended up with.

For clarity, this will only provide a list of NID's that DO NOT have an associated menu item.

I've also added a WHERE clause to limit content types, as some content types will naturally be excluded because of the way they was architected. 

SELECT n.nid, n.type, n.title, n.status
FROM node AS n
WHERE (n.type = 'article' OR n.type = 'page')
AND n.nid NOT IN (
  SELECT REPLACE(link_path, "node/", "") AS nid
  FROM menu_links
  WHERE SUBSTRING(link_path, 6, LENGTH(link_path)) REGEXP "^[0-9]+$" 
);