mysql问题,跪求高手解答
select c.globalUid,c.badge,temp.sumB,temp.sumP from tb_user c,(select a.uid,sum(a.badge) as sumB,IFNULL(sum(b.propertyNum),0) as sumP,sum(a.badge)-IFNULL(sum(b.propertyNum),0) as cha from tb_buyfun_log a left join buyrecord b on a.uid=b.globaluid group by a.uid having cha>500) as temp where uptime>'2009-12-01 00:00:00' and globaluid=temp.uid
谁帮忙优化下这语句,我在电脑上运行后很慢,有时半天都不出来,有时连查询工具都搞起死掉,关也关不了, 各位高手帮忙看下好不?
SQL code:
select c.globalUid,c.badge,temp.sumB,temp.sumP
from tb_user c,(
select a.uid,sum(a.badge) as sumB,
IFNULL(sum(b.propertyNum),0) as sumP,
sum(a.badge)-IFNULL(sum(b.propertyNum),0) as cha
from tb_buyfun_log a left join buyrecord b on a.uid=b.globaluid
group by a.uid
having cha>500
) as temp
where uptime>'2009-12-01 00:00:00' and globaluid=temp.uid
你这是个笛卡积啊。
贴出你的
show index from tb_user
show index from tb_buyfun_log
show index from buyrecord
以及
explain select c.globalUid,c.badge,temp.sumB,temp.sumP
from tb_user c,(
select a.uid,sum(a.badge) as sumB,
IFNULL(sum(b.propertyNum),0) as sumP,
sum(a.badge)-IFNULL(sum(b.propertyNum),0) as cha
from tb_buyfun_log a left join buyrec
相关问答:
有个winform程序,使用c#+mysql,需要在一个窗体设置mysql自动删除功能,包括自动删除多少天之前的数据以及是否开启自动删除功能,我程序退出后,还怎么控制Mysql自己删除啊?是不是要用mysql的event来实现?c#可以调用mysq ......
不知道是不是我的xampp有问题,mysql是图形化的!
一个ID组在我的mysql的表里面 2,5,8,7
点了排序,然后用PHP文件连接这个表显示表的信息时,ID的顺序还是不变!应该是2,5,7,8的吧升序排序后!
在PHP文件里 ......
大家帮我看下吧,本来数据库没有东西,能显示没有东西的信息,但是我添加了一条内容后,字没了,但是图片也无法显示,红叉叉也没有,怎么回事啊?
PHP code:
<?php
$str="select * from product wh ......
我在清理mysql的时候,一不留神将mysql(即data里的mysql文件夹)数据库给删掉了,隔了几个小时我重启了mysql软件,mysql就自动初始化了数据库,导致从删除mysql文件夹开始到重启这段时间的数据丢失,那位高手帮想想办 ......