How to Group By This Comma-Delimited Data
I have data like this :
ID Book Author
1 Book A Andy, Brian
2 Book B Andy, Charlie
3 Book C Brian
How to group by the data so i can get like this:
Author Count
开发者_StackOverflow中文版Andy 2
Brian 2
Charlie 1
If we assume you have a normalized structure, you simply need to :
SELECT a.author, count(*)
FROM books b
INNER JOIN author a ON a.author_id=b.author_id
GROUP BY a.author
精彩评论