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

前端之家收集整理的这篇文章主要介绍了php中使用临时表查询数据的一个例子前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

猜你在找的PHP相关文章