0
select SQL_NO_CACHE a.id,
date_format(a.data_cron,'%d/%m/%Y às %H:%i:%s') as data_pt,a.msgal,
a.status,
b.nome,
c.msg,
if((select count(*) from moips_temps where envio_id=a.id group by envio_id) > 0,1,0) as senvio,
if((select count(*) from moips_temps2 where envio_id=a.id group by envio_id) > 0,1,0) as senvio2
from moips_envios a,
moips_listas b,
moips_msgs c
where a.lista_id = b.id
and a.msg_id = c.id
and a.moips_id = 44
order by a.id desc
時間:0.0146雙左加入與MySQL的雙重計數?
select SQL_NO_CACHE a.id,date_format(a.data_cron,'%d/%m/%Y às %H:%i:%s') as data_pt, a.msgal, a.status, b.nome, c.msg,
if(count(d.envio_id) > 0,1,0) as senvio,
if(count(e.envio_id) > 0,1,0) as senvio2
from moips_envios a
left join moips_temps d
on a.id=d.envio_id
left join moips_temps2 e
on a.id=e.envio_id, moips_listas b, moips_msgs c
where a.lista_id=b.id
and a.msg_id=c.id
and a.moips_id=25
group by a.id
order by a.id desc
時間:0.1107
爲什麼與子查詢數更快速?
PLS格式的代碼/查詢 - 比較難讀,我們要幫助的可能性就越小。 – 2012-04-15 03:32:26
好吧,我會做的秒 – 2012-04-15 03:33:15
沒有1可以解釋它對我? – 2012-04-15 04:06:01