Thread Starter
eiland
(@eiland)
This goes a while, but needs to undouble:
SELECT term3.slug, term2.slug, term1.slug, wp_terms.slug, wp_posts.post_name
FROM wp_posts
LEFT JOIN (
wp_postmeta,
wp_terms,
wp_terms AS term1,
wp_terms AS term2,
wp_terms AS term3,
wp_term_taxonomy,
wp_term_taxonomy AS tax1,
wp_term_taxonomy AS tax2,
wp_term_taxonomy AS tax3
) ON (
wp_posts.ID = wp_postmeta.post_id
AND wp_terms.term_id = wp_postmeta.meta_value
AND wp_postmeta.meta_key = "_category_permalink"
AND wp_terms.term_id = wp_term_taxonomy.term_id
AND wp_term_taxonomy.parent = term1.term_id
AND term1.term_id = tax1.term_id
AND tax1.parent = term2.term_id
AND term2.term_id = tax2.term_id
AND tax2.parent = term3.term_id
)
Thread Starter
eiland
(@eiland)
sorry:
SELECT DISTINCT wp_terms.term_id, wp_postmeta.post_id, term3.slug, term2.slug, term1.slug, wp_terms.slug, wp_posts.post_name, wp_posts.post_title
FROM wp_postmeta
LEFT JOIN wp_posts ON wp_postmeta.post_id=wp_posts.ID
LEFT JOIN wp_terms ON wp_postmeta.meta_value=wp_terms.term_id
LEFT JOIN wp_term_taxonomy ON wp_term_taxonomy.term_id = wp_terms.term_id
LEFT JOIN wp_terms AS term1 ON term1.term_id = wp_term_taxonomy.parent
LEFT JOIN wp_term_taxonomy AS tax1 ON tax1.term_id = term1.term_id
LEFT JOIN wp_terms AS term2 ON term2.term_id = tax1.parent
LEFT JOIN wp_term_taxonomy AS tax2 ON tax2.term_id = term2.term_id
LEFT JOIN wp_terms AS term3 ON term3.term_id = tax2.parent
WHERE wp_postmeta.meta_key = "_category_permalink"