Home » Performance » MySQL » Joining rows based on their timestamp
Joining rows based on their timestamp [message #3173] Wed, 11 June 2008 21:02
pytrin  is currently offline pytrin
Messages: 1
Registered: June 2008
Junior Member
I'm building a simple message-board like app. For every topic there could be several posts, and I would like to present the topic in a list with some content from the latest post in that topic.
Simplifying it, say I have two tables:

Topics:
- id (INT / AI )
- subject (VARCHAR(150))
- created (TIMESTAMP)

Posts:
- id (INT / AI)
- topic_id (INT / FK)
- content (TEXT)
- created (TIMESTAMP)

I want to retrieve rows from the Topics table, along with the latest row for each topic from the Posts table.
Can anyone suggest the most efficient way of accomplishing this (hopefully without a GROUP BY clause)?
Previous Topic:STR_TO_DATE does not function when using only year and month?
Next Topic:LIMIT starting at high row count very slow
Goto Forum:
  


Current Time: Sun Jul 5 17:25:27 EDT 2009

Total time taken to generate the page: 0.01093 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.