Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT problem..

Status
Not open for further replies.

jamesp0tter

Programmer
Feb 20, 2003
119
PT
well, i built a forum that works with one table.. i've got (almost) everything working out now, i only need to get the threads ordered by their last post.

my forum table:
id | id_topic | id_thread | id_msg | type | date | more that doesn't matter

type can be 'thread', 'topic' or 'msg'

data is 'd-m-Y-H-i' (so that i can explode the '-'s and work like i want with it)

imagine i have thread 2 under topic 1, that'll be:

nn | 1 | 2 | 0 | 'thread' | 12-03-2003-15-30

and a message inside that topic is:

nn | 1 | 2 | 9 | 'msg' | 13-03-2003-14-45 |

question:
i need to get the threads from topic 1 sorted so that they apear ordered by their last entered message..
how ? :)

tkx in advance for your help
 
If I've understood what you want correctly, it could be as simple as:

SELECT DISTINCT(id_thread) FROM table WHERE id_topic='1' AND type='msg' ORDER_BY date DESC

That may need a little tweaking, but it should be pretty close.

Best wishes,
Simon. Domain Name Back Ordering & Monitoring
$8.95 Full Service Domain Registrations
 
well, that did work, with some tweaks, but i'm going into a different strategy, i'll put a field named 'last_post' in the table so that each thread as it. and that way i'll be able to sort things right :)

tkx 4 ur help NameAlerts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top