查询 article 根据 article 的记录数大于两条记录的

解决方案 »

  1.   

    有点象:
    select id from article group by id having count(*)>2
      

  2.   

    select * from article as A where (select count(*) from article where id > A.id) > 2
    如果ID值大于查询的当前ID的记录有2条以上时,这样的记录被找出来。
      

  3.   

    关键是在子查询中:where id > A.id不太好理解,因为id都是aritcle表中的!
      

  4.   

    关键是在子查询中:where id > A.id不太好理解
      

  5.   

    select * 
    from article 
    where id in (select id 
                 from article 
                 group by id 
                 having count(*) > 2)
    这个语句的目的是获取多条id的记录
    这样写因为不知道article 表中的具体列
    当然可以写成
    select id,colum1,colum2... 
    from article 
    group by id,colum1,colum2... 
    having count(*) > 2select * from article as A where (select count(*) from article where id > A.id) > 2
    这种写法很不容易理解的,实际运用中最好不要这样写。
    且表的别名最好用小写字母,一种习惯吧:)
    实际开发中不用as别名的直接空格一个别名,没什么道理程序开发的习惯。
    呵呵
      

  6.   

    select * from article as 别名 where (select count(*) from article where id > 别名.id) > 2