Skip to main content

Useful DB Queries for Drupal Applications

Submitted by system on
Show grouped node counts based on OG group ids for nodes created after a particular time stamp select gid, count(*) from og_membership inner join node on og_membership.etid = node.nid and node.created >= 1678127400 group by gid;
Show node type specific node count list select type,count(*) from node group by type;
Show group membership wise node counts select gid,count(*) from og_membership group by gid;
Start the node next Increment number from a specific nid ALTER TABLE node AUTO_INCREMENT = 20000000;
ALTER TABLE node_revision AUTO_INCREMENT = 20000000;

Show nodes with highest revisions limit 20. SELECT nid, COUNT(vid) AS count FROM node_revision GROUP BY nid ORDER BY count DESC LIMIT 20;
Show number of revisions for a node SELECT nid, COUNT(vid) AS count FROM node_revision WHERE nid=292099