Home > Mobile >  Find the top 10 most commonly used words?
Find the top 10 most commonly used words?

Time:10-10

tell me a way to find out the most commonly used words

CodePudding user response:

Different approach, use a rank function and then Inner Join to tags table:

Select t.tag_name
From tags t Inner Join (
    Select tag_id, rank() Over (Order By taguse desc) as tagrank
    From (Select tag_id,count(tagid) as taguse From phototags Group By tag_id)
) p On t.id=p.tag_id
Where tagrank<=5
    

CodePudding user response:

Haven`t written on MySQL, but in MS.Access the following code will work:

SELECT tag_name
FROM tags 
LEFT JOIN photo_tags on tag_name.id= photo_tags.tag_id
GROUP BY photo_tags.tag_id
ORDER BY COUNT(tag_id) DESC
LIMIT 5

it just allows to JOIN tables without showing any of the columns from it.

  • Related