php - Storing most frequently used values in an array from database -


what i'm trying top 3 frequent values column in database, have searched solution couldn't find anything. have code used;

 $mostfrequentuser = $db->query("select emailfrom details group emailfrom having count(*) = (select count (*) details group emailfrom order count(*) desc limit 1)");  $frequent = $mostfrequentuser->fetchcolumn(); 

it's can order them 1 - 3 of uses system , display on webpage, great! thanks

try following

select emailfrom  (     select emailfrom, count(emailfrom) mycount     details     group emailfrom      order mycount desc     limit 3     ) temp 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -