Skip to content

Instantly share code, notes, and snippets.

@techieshark
Created January 10, 2012 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techieshark/1591895 to your computer and use it in GitHub Desktop.
Save techieshark/1591895 to your computer and use it in GitHub Desktop.
(Drupal) SQL to count #nodes in each term in each vocabulary.
SELECT v.vid, v.name AS Vocabulary, td.tid, td.name AS Term, (SELECT count(*) FROM drupal_node n JOIN drupal_term_node tn2 ON n.nid = tn2.nid WHERE tn2.tid = td.tid) AS Count FROM drupal_vocabulary v JOIN drupal_term_data td ON v.vid = td.vid ORDER BY Count DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment