HEre is my table structure
topic has many threads
Thread has many posts
When i want display all the threads in a topic i want to sort it by last post ( if there any reply of a thread. other wise sort it by thread DESC..)
The following query works but it duplicate all the thread id,
if i have thread it 1,2,3 it keeps repeating.. I wanted group them by thread_id but i can't use as I m using ORDER BY sorting by post_date .
Thanks
SELECT thread_id, thread_title, post_title, post_date FROM thread, post WHERE thread_topic = 1 AND thread_id = post_thread
ORDER BY post_date DESC