Not sure Looking for some guidance here...
I have the following tables:
site_text
id site_id text date_added
1 1 ... 2010-02-02 10:01:00
2 1 ... 2010-02-02 10:01:20
3 2 ... 2010-02-02 10:01:00
4 1 ... 2010-02-02 10:01:40
5 2 ... 2010-02-02 10:02:00
sites
id site_name
1 www.a.com
2 www.b.com
....
I'm trying to select the last 2 rows (ordered by date desc) in site_text for each site. Can you do this with one query? Something like, but have it only find 2 rows of each site?
SELECT *
FROM site_text st
JOIN sites s ON st.site_id = s.id
WHERE st.date_added > '2010-02-01 23:32:04'
ORDER BY s.id, st.date_added DESC
EDIT: In the end, I would be looking for rows 4,2,5,3.