MySQLFilter: I'm looking for a way to display a list of recent entries from multiple blogs I have stored in a MySQL database, but allow only one entry per blog to be included in the list. What should I add to the WHERE clause?
I've got a SELECT statement that's working right now but doesn't prevent multiple entries from the same blog. For example, the current code would display the 4 latest entries like this:
Blog A, Entry 1 (today)
Blog C, Entry 1 (yesterday afternoon)
Blog A, Entry 2 (yesterday morning)
Blog B, Entry 1 (two days ago)
Instead I'd like it to display the latest 4 entries as:
Blog A, Entry 1 (today)
Blog C, Entry 1 (yesterday afternoon)
Blog B, Entry 1 (two days ago)
Blog D, Entry 1 (three days ago)
I'm assuming that a WHERE clause modification that focuses on the id for each blog (f.id in the statement below) can make this happen but I'm stuck on the syntax. Ideas?
Here's the statement I'm currently using:
"SELECT e.cid, e.id, e.url, e.title, SUBSTRING( e.content, 1, 250 ), e.pubdate, f.siteurl, f.title,
FROM feeds_item e INNER JOIN feeds_channels f ON (e.cid = f.id)
ORDER BY e.pubdate DESC
LIMIT 4"
posted by dentata at 7:55 PM on October 11, 2006