Export Drupal nodes to CSV

Want to extract all your content from Drupal? I bet you do… seems like the world has gotten a distaste for all things Drupal and is jumping on the WordPress or even Jekyll bandwagon. Anyway, this query will probably get you what you need:


SELECT DISTINCT no.nid, n.title, u.name, n.timestamp, n.body, group_concat(DISTINCT td.name) as terms FROM users u, node no, term_data td, node_revisions n LEFT JOIN (term_node) ON (n.nid = term_node.nid) WHERE n.uid = u.uid AND no.vid=n.vid AND term_node.tid = td.tid GROUP BY no.nid

This was inspired by a more complicated method here; but why use node.js and a long JavaScript script to do something that can be done in one SQL statement?

Disclaimer: I’m still waiting for confirmation from my collaborator that this is actually what he needs, so there might be some edits coming.