Forum Moderators: coopster

Message Too Old, No Replies

Getting 3 entries per section

         

knighty

3:37 pm on Aug 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




Lets say I have a table with a number of sections and in each section are articles with the date the article was updated.

I can easily print off :

section1 - list all entries upddated this month
section2 - list all entries upddated this month
section3 - list all entries upddated this month
etc.

BUT what if I just want :

section1 - last 3 entries
section2 - last 3 entries
section3 - last 3 entries
etc.

I could just output everything and then get php to only show 3 OR I could do multiple calls for each section and use LIMIT - is there another way?

knighty

12:17 pm on Aug 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



only using version 3x of mysql

jatar_k

4:58 pm on Aug 23, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



those are the 2 methods that come to mind. You should benchmark the 2 to see which is slower. I would think, off the top of my head, that doing the one big query and using php to output would become slower as there were more results and the other would stay at a constant speed.