因表1 表2中table1_01=tabl2_01 表2 table2_01 有重复值,而表table1_01 是唯一值,在一定条件下,我想用 count(distinct(table1_01)) as total  类似的形式求出 talbe1_01 总记录数,不重复的。
----请指教

解决方案 »

  1.   

    select count(table1.table1_01) as total from table1  inner join table2 on table1.table1_01=table2.table2_01 where table1.table1_09='".$Session_name."' and  (table1.table1_01 like 'J62%' or table1.table1_01 like 'L62%' or table1.table1_01 like 'P62%') and  table2_121<>'Y' group by table1.table1_01
      

  2.   

    select count(table1.table1_01) as total from table1  inner join table2 on table1_01=table2_01 where table1_09='".$Session_name."' and  (table1_01 like 'J62%' or table1_01 like 'L62%' or table1_01 like 'P62%') and  table2_121<>'Y'应该直接用count(*) as total 就可以了.
      

  3.   

    直接用COUNT而不用GROUP BY 的话会有楼主说的记录重复的问题的。