Skip to content
Advertisement

return number of hashtag posts sql, mysql

I have two tables, 1) hashtags table & 2) hashtags_relation table.

The first one lists the hashtags, and the second one relates the hashtag with a post.

TABLE HASHTAGS

EXPECTED OUTPUT

SQL QUERY (MYSQL)

PROBLEM

How do I get, the number of posts of each hashtag? I tried using ht.count(*)

Advertisement

Answer

You need to use GROUP BY:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement