??
select count(*) from table where userid=2

解决方案 »

  1.   

    select count(*) 发贴数量 from table where userid=2
      

  2.   

    在此所求的参与的贴子数量是指为根贴子的数量,即FATHER=0,如:
    某一贴子不是该用户发起的,但该用户在该贴下有跟贴且不管跟多少次,则该贴也算.
      

  3.   

    算:
    select count(distinct FATHER) from table where userid=2
    不算:
    select count(distinct FATHER) from table where userid=2 and father<>0
      

  4.   

    其实就跟CSDN的本版我参与问题一样的,根贴子算是问题,不是根贴子就算是参与的了.当然所提的问题也算.不过用select count(distinct FATHER) from table where userid=2
    的话,要是我提了10问题,则得到的结果却是1
      

  5.   

    select (select count(*) from table where userid=2 and father=0)+(select count(distinct FATHER) from table where userid=2 and father<>0) as 参与数