skip to Main Content

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

2

Answers


  1. 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
        
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search