i have the database where a field counts the visiting numbers. everytime I'm trying to show top visited keyword with mysql max() function. I can't make the query. please help me. i want to select data by checking top visited field and get it as rows.
Does it add another row to the DB or does it update a row? It sounds like you need something like this. SELECT * FROM db ORDER BY COUNT(field) DESC LIMIT 1; If you are Updating a column, you would probably need something like this: SELECT * FROM db ORDER BY MAX(field) DESC LIMIT 1;
thanks, second query makes sense to me. it must be the right query. actually nothing about adding another row. my keyword table is like this: id=1, keyword=music, visit=300; id=2, keyword=movie, visit=400 I was trying to get these rows where order would be by max(visit) .. here movie would be top keyword...