Select count for each distinct row (mysql and php)

前端 未结 1 1318
孤城傲影
孤城傲影 2021-02-19 03:42

I am using mysql and php.

I have a table with one column. I can show unique rows by:

select distinct id from id_table

This might show<

1条回答
  •  情话喂你
    2021-02-19 04:04

    select id, count(id)
    from table
    group by id
    

    If only want count of ids, then

    select count(id)
    from table
    group by id
    

    Here is a simple tutorial of group by clause

    http://www.w3schools.com/sql/sql_groupby.asp

    0 讨论(0)
提交回复
热议问题