[PHP-DB] An SQL-query puzzle... SELECT max 2 rows from tables having id 'a' or id ' b' or id 'c'... From: Trond Erling Hundal (webmaster <email protected>)
Date: 11/20/00

Hey hey hey...
I`ve stumbled across a little SQL puzzle here... maybe some of you can
help...
I am building a "main page" for many "sub main pages"
The idea is to have several pages displaying newsflashes for their specific
subject...
Example:
Main page 1 only contains news about a place called Grewin
Main page 2 only contains news about a place called Orklan
Main page 3 only contains news about a place called Lillo
Main page 4 only contains news about a place called Dogmax

The news for these sites have already been stored in a MySQL table called
article.
The relation between the article and the specific site is stored in a table
calles newsportal.
NOW, I want to select the 2 top stories from each of these portals, to
display them on a "main-main page"...
So the main page displayes the two newest articles from page 1, 2, 3 and 4.
A total of eight articles in this case...

Maybe this is really easy, or maybe I have to reconstruct the db....
I`m using MySQL....

Any ideas will be GREATLY appreciated!

--------------------------
Maybe something like this:
SELECT article.story as story, article.date as date FROM article, newsportal
WHERE article.articleid = newsportal.articleid AND newsportal.portalid = 1
OR newsportal.portalid = 2 OR
newsportal.portalid = 3 OR newsportal.portalid = 4 ORDER BY date DESC LIMIT
0, 8
---- no , that wasn`t right... But maybe it`ll help you understand... :)

>From SQL puzzler!

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>