topacoBoy topacoBoy - 1 year ago 38
MySQL Question

How can i get the total of a column in mysql?

Alright, I am kind of new to SQL and I have no idea on how I am going to do this. I have tried to google but maybe I'm not sure if I am searching for the right question. So here it is. I have 2 tables in my database. One is called

and another one is called

table looks like this..

eventID | eventName|
1 | eveA |
2 | eveB |
3 | eveC |

and my
table, looks like this

eventCat |UserRegistered |
1 | John |
2 | Mac |
3 | Assz |
2 | Ez |
3 | Pz |

(I hope you understand my table.....)


Now, what I am trying to do is to, calculate the numbers of participants for event 1, 2 and 3 in
table and later display the number of users who will be attending appropriately by using the
table using php.

Can somebody help me out with this ? Thanks a bunch !

Answer Source

You can apply join and group by to acheive this -

SELECT count(UserRegistered),eventName from events join eventtype on
     GROUP BY eventCat

Hope this will help you.