Adding GROUP BY in Custom Query not working with ORDER BY

Question

Below is my query

 $wpdb->get_results("SELECT * FROM wp_posts WHERE post_type="episode" GROUP BY post_parent ORDER BY post_modified DESC  LIMIT 32;");

it doesn’t sort with post_modified DESC, but if I remove GROUP BY post_parent, it perfectly displays all recently updated posts. Is there any way to handle this ? Following query works if I remove GROUP BY…

 $wpdb->get_results("SELECT * FROM wp_posts WHERE post_type="episode" ORDER BY post_modified DESC  LIMIT 32;")

0
Themer 1 month 2021-06-30T09:51:32-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse