You are here: Re: mysql limit... need TOP 20 not FIRST 20.... « PHP SQL « IT news, forums, messages
Re: mysql limit... need TOP 20 not FIRST 20....

Posted by hoonew on 07/13/05 06:37

Then you need an ORDER BY clause, maybe:

SELECT sw.swid, title, shortdesc, version, catid, count(dl.swid),warename
FROM software sw
LEFT JOIN downloads dl ON sw.swid = dl.swid
JOIN waretypes wt ON sw.wareid = wt.wareid
WHERE liveyn = 'y'
GROUP BY
sw.swid, title, shortdesc, version, catid
ORDER BY count(dl.swid) DESC
limit 20

toedipper wrote:
> Hello,
>
> I have the folowing query.
>
> SELECT sw.swid, title, shortdesc, version, catid, count(dl.swid),warename
> FROM software sw
> LEFT JOIN downloads dl ON sw.swid = dl.swid
> JOIN waretypes wt ON sw.wareid = wt.wareid
> WHERE liveyn = 'y'
> GROUP BY
> sw.swid, title, shortdesc, version, catid
> limit 20
>
>
> It works but it just gives me the first 20 records. I select from a
> software table and then join to a downlaods table and count instances of
> a software id, each instance is a downloand.
>
> What I really want is for the 20 to show the TOP 20 downloads
> (instances. I think what I am looking for is an equivalent statement to
> the TOP in MS Sql.
>
> Any ideas?
>
>
> Thanks,
>
> td.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация