php中使用临时表查询数据的一个例子

yipeiwu_com6年前PHP代码库

复制代码 代码如下:

$sql3="CREATE TEMPORARY TABLE atmp_table(uid int(11),dnum int(20) not null)"; 
mysql_query($sql3); 
$sql3="INSERT into atmp_table(uid,dnum) SELECT uid,count(soid) as dnum 
        FROM `cy_score2` 
        where (nei='下载' or nei='下载试题')   
        group by uid having dnum>150 
        order by dnum desc limit 10"; 
mysql_query($sql3); 
$sql3="select a.uid,count(b.tid) as unum from atmp_table a left join cy_test b on a.uid=b.uid 
        group by b.uid 
        order by a.dnum desc,unum asc limit 5"; 
$query4=mysql_query($sql3); 
$rs=mysql_fetch_array($query4) ;

相关文章

php json中文编码为null的解决办法

今天使用json_encode函数,发现中文竟成了null。 原因分析:使用json_encode函数应应使用utf-8编码,我的页面用的是gbk. 解决:在json_encode函数前...

PHP的Yii框架中YiiBase入口类的扩展写法示例

通过yiic.php自动创建一个应用后,入口文件初始代码如下: <?php // change the following paths if necessary $yi...

PHP配置ZendOpcache插件加速

PHP配置ZendOpcache插件加速

php原版本情况: [root@www sbin]# php -v PHP 5.6.23 (cli) (built: Dec 7 2018 09:00:11) Copyright...

strpos() 函数判断字符串中是否包含某字符串的方法

用php的strpos() 函数判断字符串中是否包含某字符串的方法 判断某字符串中是否包含某字符串的方法 if(strpos('www.idc-gz.com','idc-gz') !...

thinkphp修改配置进入默认首页的方法

thinkphp文件夹下config 里面有个convention.php文件 里面有三个配置 'DEFAULT_MODULE' => 'Home', // 默认模块 'DEF...