* Veysel Harun Sahin
> The two columns of my table are name and city. I am trying to do
> a list which contains only the different names. This can be done
> this by distinct keyword. But all the same names which have
> different cities also have to be included in my list. So I can
> not do this with a distinct keyword.

You can use the GROUP BY clause with two columns:

SELECT name,city,count(*)
  FROM my_table
  GROUP BY name,city

The count(*) will give you a count of how many rows have each name/city
combination. If you don't need it simply remove it, the GROUP BY should work
anyway.

--
Roger


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to