Page 1 of 1

Selecting Newest Articles By Unique Authors

Posted: Tue Jan 08, 2008 12:57 am
by mr_griff
I am trying to figure out how I can select the most recent articles added to a MySQL table but not repeat any authors.

I have tried this:

Code: Select all

SELECT DISTINCT authorID, articleID, articleTitle FROM articles ORDER BY dateAdded DESC LIMIT 3
But the results will contain repeated authors, which is what I am trying to avoid. Any thoughts...

Posted: Tue Jan 08, 2008 4:22 am
by Inkyskin
You could try this way:

Code: Select all

SELECT DISTINCT(authorID), articleID, articleTitle FROM articles ORDER BY dateAdded DESC LIMIT 3

Posted: Tue Jan 08, 2008 3:01 pm
by superdezign
Maybe you could try to make use of the GROUP BY clause.

Code: Select all

SELECT `tableName`.*, MAX(`tableName`.`dateAdded`) FROM `tableName` GROUP BY `tableName`.`author`;