[wp-hackers] SELECT DISTINCT .... ORDER BY not working....

Computer Guru computerguru at neosmart.net
Mon Nov 19 21:18:37 GMT 2007


Can someone *please* tell me what is wrong with this query!? I've been
bouncing my head off the walls trying to get it to work right, but to no
avail.

Original query:
SELECT comment_post_id FROM wp_comments
   WHERE comment_approved = '1'
ORDER BY comment_date DESC

That works just fine. But the minute I try to get distinct comment_post_id,
the sorting stops working:

SELECT DISTINCT comment_post_id FROM wp_comments
   WHERE comment_approved = '1'
ORDER BY comment_date DESC

It filters comment_post_id just fine (only one comment per post) but my
results are no longer ordered correctly!

Using GROUP BY instead of distinct gives me the same un-ordered output.

Any advice would be mighty appreciated.

-- 
Computer Guru
Director,
NeoSmart Technologies
http://neosmart.net/blog/


More information about the wp-hackers mailing list