andrei
andrei

Reputation: 8582

mysql count query

I have a mysql table set up like this

id | refference_id | data

Is it possible to count the number of entries for each refference_id all in the query ?

Upvotes: 0

Views: 149

Answers (2)

Peter Perháč
Peter Perháč

Reputation: 20782

select count(distinct refference_id) as myResult from myTable;

Upvotes: 0

Julien Hoarau
Julien Hoarau

Reputation: 49970

SELECT
  refference_id,
  COUNT(*)
FROM
  table
GROUP BY
  refference_id 

Upvotes: 1

Related Questions