![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #1 |
|
Regular Coder ![]() Join Date: Sep 2004
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Distinct records ordered by date
I have the basis of a forum similar in workings to this one. I am using perl with MySQL the problem i have is a simple SQL one.
I have a table storing all post data including fields. forumID, threadID, postID, postTitle, datePosted, timePosted I want to list the threads in the order of last posted/replied to. So similar to this you click on the forum you want view and you get a list of the threads in that forum with the most recently active at the top. I don't mind how much data i can get for each thread, i can handle just getting the threadID and then i can loop back through it again and get the specific data for that thread (infact this would be preferable as it would give me more control although would work the server alittle harder). the closest SQL i have to working is Code:
SELECT DISTINCT threadID FROM postdata WHERE forumID='$fid' ORDER BY dataPosted, timePosted DESC; SQL is not my best subject, any ideas welcome |
|
|
|
|
|
PM User | #2 |
|
Regular Coder ![]() Join Date: Oct 2002
Posts: 379
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Does this work in mySQL?
PHP Code:
__________________
Strategy Conscious Last edited by Kiwi; 02-10-2005 at 06:49 AM.. |
|
|
|
|
|
PM User | #3 |
|
Regular Coder ![]() Join Date: Sep 2004
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
no that just brings up an error. i've given up trying to so it in SQL. i just get an ordered list of thread IDs and remove the duplicate items in perl. i think each thread has to make about 5 database queries to get all the information now
|
|
|
|
|
|
PM User | #4 | |
|
New to the CF scene Join Date: Feb 2005
Location: Derby, UK
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Quote:
WHERE a.forumID='$fid' |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|