mysqlwordpresstags

How to get the Tag list in WordPress using MySQL


I want to get the following information from a WordPress database related to Tags:

  1. TagID
  2. TagName
  3. TagPostCount

I need a MySQL SQL command. Please don't show me PHP code. Thanks!


Solution

  • It's a MYSQL query against a wordpress db with "wp_" table prefix (the default)

    SELECT wp_terms.`term_id` AS TagID, wp_terms.`name` AS TagName, SUM( tax.`count` ) AS TagPostCount
    FROM `wp_terms`
    INNER JOIN wp_term_taxonomy tax ON tax.term_id = wp_terms.term_id
    GROUP BY wp_terms.`term_id`