Re: [PHP] Determining Top # from MySQL

2010-04-11 Thread Floyd Resler
On Apr 10, 2010, at 10:02 PM, Ashley M. Kirchner wrote: > > > Given a MySQL query like this $q = "select num from table", I get a result > like this: > > > > +---+ > > |num| > > +---+ > > | 1| > > | 4| > > | 6| > > | 2| > > | 4| > > | 5| > > | 3| > > | 2| > > | 4| > > |

Re: [PHP] Determining Top # from MySQL

2010-04-10 Thread vikash . iitb
If you want to take top 5: SELECT num, COUNT( num ) as c FROM table GROUP BY num order by c desc limit 5 Thanks, Vikash Kumar -- http://vika.sh On Sun, Apr 11, 2010 at 8:07 AM, Dan Joseph wrote: > Eh, he's off topic, but we've talked plenty SQL on here before... > > SELECT num, COUNT( num ) F

Re: [PHP] Determining Top # from MySQL

2010-04-10 Thread Dan Joseph
Eh, he's off topic, but we've talked plenty SQL on here before... SELECT num, COUNT( num ) FROM table GROUP BY num; I don't have a myqsl server to test that, but should do it. -- -Dan Joseph www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month. Promo Code "NEWTHINGS" for 10% off

Re: [PHP] Determining Top # from MySQL

2010-04-10 Thread Kevin Kinsey
Ashley M. Kirchner wrote: Given a MySQL query like this $q = "select num from table", I get a result like this: +---+ |num| +---+ | 1| | 4| | 6| | 2| | 4| | 5| | 3| | 2| | 4| | 2| | 3| | 3| | 2| | 1| +---+ What I want is a listing of numbers sorted by the amoun