select st_id,st_day,st_sc_id,st_s_id,st_p_id,st_nums tdn,st_money tdm
from sum_total where st_id in (select max(st_id) from sum_total where
st_day<=1286121600 and st_sc_id=8 and st_s_id=31
group by st_s_id,st_p_id)
这句SQL应该怎么样优化下才可以执行的快一点么?求大侠指点
from sum_total where st_id in (select max(st_id) from sum_total where
st_day<=1286121600 and st_sc_id=8 and st_s_id=31
group by st_s_id,st_p_id)
这句SQL应该怎么样优化下才可以执行的快一点么?求大侠指点
数据库为MYSQL
好像是st_id in 的原因执行很缓慢,所以想求教下这样的句子应该怎么优化下~
from sum_total a inner join
(select max(st_id) as ma from sum_total where
st_day<=1286121600 and st_sc_id=8 and st_s_id=31
group by st_s_id,st_p_id) b on a.st_id=b.ma