2011-11-03 35 views
0

检索过去后我对WordPress的下面的代码:JOIN查询特定类别

SELECT terms.*, posts.ID as post_ID 
FROM wp_terms terms 
JOIN wp_term_taxonomy term_taxonomy 
    ON terms.term_id = term_taxonomy.term_id 
JOIN wp_term_relationships term_relationships 
    ON (term_relationships.term_taxonomy_id = term_taxonomy.term_taxonomy_id 
     AND term_taxonomy.taxonomy = 'category') 
JOIN wp_posts posts 
    ON (posts.ID = term_relationships.object_id 
     AND posts.post_type='post' 
     AND posts.post_status='publish') 
WHERE terms.term_id=19 OR terms.term_id=20 OR terms.term_id=21 OR terms.term_id=22 
GROUP BY terms.term_id 
ORDER BY posts.post_modified_gmt DESC 

我要检索特定类别的最后一个职位。但它返回每个类别的第一篇文章。我究竟做错了什么?

回答

0

尝试删除DESC关键字。

+0

同样的结果与不同的排序......但再次第一篇文章每猫 – zuperakos

+0

我仍然在努力解决问题,但我找不到解决方案。我试图插入“order by”语句到JOIN中,但它返回错误。 – zuperakos