2011-11-03 56 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