complex mysql query problem
Posted
by Scarface
on Stack Overflow
See other posts from Stack Overflow
or by Scarface
Published on 2010-04-21T02:30:14Z
Indexed on
2010/04/21
2:33 UTC
Read the original article
Hit count: 342
mysql
Hey guys I have a query that selects data and organizes but not in the correct order. What I want to do is select all the comments for a user in that week and sort it by each topic, then sort the cluster by the latest timestamp of each comment in their respective cluster. My current query selects the right data, but in seemingly random order. Does anyone have any ideas?
select * from (
SELECT
topic.topic_title, topic.topic_id
FROM comments
JOIN topic ON topic.topic_id=comments.topic_id
WHERE comments.user='$user' AND comments.timestamp>$week order by comments.timestamp desc) derived_table
group by topic_id
© Stack Overflow or respective owner