MySQL - Using COUNT(*) in the WHERE clause

前端 未结 9 1685
不思量自难忘°
不思量自难忘° 2020-11-28 20:55

I am trying to accomplish the following in MySQL (see pseudo code)

SELECT DISTINCT gid
FROM `gd`
WHERE COUNT(*) > 10
ORDER BY lastupdated DES         


        
9条回答
  •  -上瘾入骨i
    2020-11-28 21:38

    i think you can not add count() with where. now see why ....

    where is not same as having , having means you are working or dealing with group and same work of count , it is also dealing with the whole group ,

    now how count it is working as whole group

    create a table and enter some id's and then use:

    select count(*) from table_name
    

    you will find the total values means it is indicating some group ! so where does added with count() ;

提交回复
热议问题