I'm trying to get the results from this question (SO 2429348 - Help with a SQL query) except I need it to return values 1 and 3.
Edit: GROUP BY loses all except the first unique value, so replacing min with max will not work.
Edit: I didn't want to show what I'm working with but I guess I will: Here is the table called 'test_posts'
ID smallint(6)
Thread smallint(6)
Board smallint(6)
post text utf8_general_ci
name text utf8_general_ci
trip text utf8_general_ci
ip text utf8_general_ci
Date datetime
I'm trying to set up a query that shows the first post of each thread and is ordered by the date of the last post in each thread. I got the first part down with this query:
SELECT *
FROM (
SELECT Min( ID ) AS MinID
FROM test_posts
GROUP BY Thread
)tmin
JOIN test_posts ON test_posts.ID = tmin.MinID
Now I need to figure out how to call the last post of each thread into a table, than use that table to order the first tables results.