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

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -