Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySql Select all data from column and count

Tags:

c#

.net

sql

mysql

iis

I am selecting with this Command all the rows from column:

SELECT city From Users

With this i am getting all the cities from my table.

Now i want to select all the column data and the count for each one.for example:

New York 20
Los angeles 46
London 35

What should be the command for this?

like image 817
YosiFZ Avatar asked Jul 05 '13 10:07

YosiFZ


1 Answers

You can use a GROUP BY

SELECT City, COUNT(Field)
FROM Users
GROUP BY City
like image 144
Darren Avatar answered Oct 14 '22 00:10

Darren