MySQL: Count entries without grouping?

前端 未结 6 997
予麋鹿
予麋鹿 2021-02-07 06:32

I want to pull results and count how many of each name is pulled but without grouping...

for example I want this:

John Doe 3
John Doe 3
John Doe 3
Mary J         


        
6条回答
  •  醉梦人生
    2021-02-07 06:54

    SELECT  mo.*,
            (
            SELECT  COUNT(*)
            FROM    mytable mi
            WHERE   mi.name = mo.name
            )
    FROM    mytable mo
    

提交回复
热议问题