/* If you didn't know it yet, this kind of comment works in MySQL (writting it there as it was suprise to me) */ /* this query returns only ONE row for each different value in `SOME_COLUMN` Warning: fields in returned rows are taken from some unspecified row of a group */ SELECT * FROM `MY_TABLE` /* WHERE Something=something etc. */ GROUP BY `SOME_COLUMN` ; /* This query returns same as above, WITH counts of rows having given VALUE in `MY_COUNT` column (it's added ``on-the-fly'' to output) */ SELECT *, COUNT(`SOME_COLUMN`) as `MY_COUNT` FROM `MY_TABLE` /* WHERE Something=something etc. */ GROUP BY `SOME_COLUMN`