Fero
Fero

Reputation: 13315

Need to Get Data from a table which contains unique id with different category in mysql

My Table Structure is:

artist_id category

1 Song

1 Song

1 Song

1 Video

1 Video

Now, my output must be

id category total

1 Song 3

1 Video 2

How this can done by using MYSQL.

Upvotes: 0

Views: 62

Answers (1)

bernhardrusch
bernhardrusch

Reputation: 11910

I think this should work (untested):

select artist_id, category, count(*) as total from table group by artist_id, category

Upvotes: 3

Related Questions