Re: Most Read Article
| From: | Shane Wright | Date: | Mon, 05 Nov 2001 15:29:11 +0000 |
| Subject: | Re: Most Read Article | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-14016@lists.php.net to get a copy of this message | ||
Hi Jord,
Provided the 'reads' field is indexed, there's no problem :)
--
Shane
On Monday 05 November 2001 3:23 pm, Jordan Elver wrote:
> Thanks, works a treat.
> How database intensive would this be if I had a lot of records in a table?
>
> Cheers,
> Jord
>
> On Monday 05 November 2001 09:47, you wrote:
> > try this...
> >
> > SELECT title,reads FROM articles ORDER BY reads DESC LIMIT 1;
> >
> > That should do the trick.. (in mySQL or PostgreSQL anyway)
> >
> > --
> > Shane
> >
> > On Monday 05 November 2001 9:36 am, you wrote:
> > > Hi,
> > > I'm trying to get the most read article out a table.
> > > The table has a title column, a read column and some others.
> > >
> > > So I wanna SELECT the title from the table and the most read figure.
> > > I tried:
> > >
> > > SELECT title, MAX(reads) FROM articles
> > >
> > > This only gets the second most read article?! If I take out the title
> > > like:
> > >
> > > SELECT MAX(reads) FROM articles
> > >
> > > Then it gets the top article number but obviously not the title.
> > >
> > > Can anyone shed some light?
> > >
> > > Cheers,
> > > Jord