使用查询中的博客ID获取博客类别和关键字

时间:2016-03-17 05:01:55

标签: mysql wordpress

我是wordpress的新手。任何人都可以帮助我如何使用MySQL查询获取博客Id的博客类别和关键词。

1 个答案:

答案 0 :(得分:0)

我得到了答案。最初我对表结构感到困惑

获取类别的查询是

 select name from wp_terms where term_id in(
select term_id from wp_term_taxonomy where term_taxonomy_id in(
 (select term_taxonomy_id from wp_term_relationships where object_id=YOUR_BLOG_ID)) and taxonomy='category');

和标签的查询是

 select name from wp_terms where term_id in(
select term_id from wp_term_taxonomy where term_taxonomy_id in(
(select term_taxonomy_id from wp_term_relationships where object_id=YOUR_BLOG_ID)) and taxonomy='post_tag');