mysql - PHP - Find out the most repeated name ( first name of last name ) from the database -


i have developed app let college student search student of college , find out detail other students within college. currently, have been recording search queries on database , want is, list of top searched student name on list. so, want add script searched name ( either first name or last name ) database , make automatically update on app.

currently working manually stuff. can give me proper solution , how can improved.

this should work you:

select first_name, count(*) num_searches  table  group first_name  order num_searches desc limit 1; 

alternatively, can remove limit 1 see names ranked in order of occurance, or set limit 10 see 10 common searches.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -