1

I try count a frequency of the names in the archive of the events. I want find who are the most active persons. My table looks like this:

+---------+---------------------+
|  event  |     names           | 
+---------+---------------------+
| event1  | name1, name2        |   
| event1  | name2, name3, name4 |   
| event1  | name4, name1, name2 |   
+---------+---------------------+

I need to help make a select with statistics like this:

name 2: 3x name 1: 2x name 4: 2x name 3: 1x

I will be thankful for any tips.

  • 1
    [*One complex way to go*](http://stackoverflow.com/questions/24585326/select-duplicated-record-and-count-record-from-comma-separated-in-mysql) but it has some limitations – M Khalid Junaid Sep 11 '14 at 17:52
  • Here is a graphic I put together, consider a DB structure like this, and your query (and DB) will be much more efficient. http://imgur.com/9pchEi3 – xDaevax Sep 11 '14 at 17:58
  • Thank for an effort. You are right. It looks really more efficient. Unfortunately, I have not a scope for changing original database. In addition, it is just one table created for collecting data from a form. It works fine for my needs. What I want is only partial output to widget on a website. It doesn't worth rewrite original database. – Tereza Vanacká Sep 11 '14 at 21:02
  • Do you have name master atleast? – Akhil Sep 13 '14 at 06:53

0 Answers0