首先平台:PHP4.0+mysql3.2(大家别BS我,我也没办法虚拟主机来的,固定了这样的配置)原来mysql5时的一个查询:$sql="SELECT count(*) as cc FROM (select distinct(ip) from analyse) as ff
现在3.2的版本不支持嵌套查询,所以改为:sql="create temporary table  `tmp` SELECT DISTINCT (ip) FROM  `analyse` ; select count(*) as  `cc` from  `tmp`";
用了临时表直接在phpmyadmin里运行通过,但在php中用$rs = $db->getRow($sql);确提示错误:
1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) as `cc` from `tmp`' at line 1谁能告诉我是怎么回事,或者谁能帮我写一个能在PHP4.0+mysql3.2的sql语句,有没有不用临时表也可以实现的方法啊。

解决方案 »

  1.   

    没有mysql 3.2try:select count(distinct(ip)) from analyse;
      

  2.   

    貌似可以,谢谢klan,有空吗 再帮我看看这个在3.2上怎么写,头疼死了。
    select visiturl,count(visiturl) as urlcount from (select distinct * from(select visiturl,ip from analyse where cometime like '%".$dates."%') as g) as h group by visiturl having count(visiturl) order by count(visiturl) desc limit 5