MySQL query help - limit and group by

From: Date: Mon, 25 Feb 2002 17:47:13 +0000
Subject: MySQL query help - limit and group by
Groups: php.db 
Request: Send a blank email to php-db+get-17272@lists.php.net to get a copy of this message
Hi there. I would like to return the 2 most recent events from my table, for each author (Author_ID). Here's my table structure (simplified). tblEvents ID Title Create_Date Author_ID Is there a way to do this with a query instead of getting every record, sorted by Author_ID, displaying the first two events, and skipping through until the Author_ID changes, then displaying the first 2 events for that Author_ID, etc. I know I could use a GROUP BY clause, but can I limit the number of records returned in each group, sorted by date? -- Faye

« previous php.db (#17272) next »