帖子圖表;Php mysql order by datetime desc
ID post_date
1 2013-10-20:01:00:00
6 2013-09-20:01:00:00
term_relationships Chart;
object_id term_taxonomy_id term_order
1 1 0
1 2 0
1 3 0
6 1 0
6 1 0
term_taxonomy Chart;
term_taxonomy_id term_id taxonomy parent
1 1 category 0
2 2 post_tag 0
3 3 post_tag 0
4 4 category 1
-
$post = $wpdb->get_results("SELECT `p`.`ID`, MAX(p.post_date) as `datetime`, `p`.`post_date`, `p`.`post_content`, `p`.`post_title`, `p`.`post_status`, `p`.`post_name`, `p`.`comment_count`, `tax`.`term_taxonomy_id`, `tax`.`term_id`, `tax`.`taxonomy`, `tax`.`parent`, `rel`.`object_id`, `rel`.`term_taxonomy_id`
FROM (`$wpdb->posts` AS p)
INNER JOIN `$wpdb->term_relationships` AS rel ON `rel`.`object_id` = `p`.`ID`
INNER JOIN `$wpdb->term_taxonomy` AS tax ON `tax`.`term_taxonomy_id` = `rel`.`term_taxonomy_id`
WHERE `tax`.`taxonomy` = 'category'AND `p`.`post_status` = 'publish' AND `p`.`post_type` = 'post'
GROUP BY tax.parent
ORDER BY datetime DESC LIMIT 4
");
tax.parent =暢銷類別ID POST_DATE型數據類型
ORDER BY日期時間DESC =不正確排序:(
如果您的代碼存在問題,請發佈結果訂單以及您的預期訂單。 – Sumurai8
我也不知道最後兩行應該說什麼。 – Sumurai8
結果由; 11.10.2013 11.10.2013 20.10.2013 .. – DerinSular