Out of resources when opening file '/tmp/#sql_3ef_3.MYI' (Errcode: 24)
SELECT oal.arc_expl_notice, oal.arc_expl_bulletin, count(*) AS total_prets, trim(concat(ifnull(notices_m.tit1,''),ifnull(notices_s.tit1,''),' ',ifnull(bulletin_numero,''), if(mention_date, concat(' (',mention_date,')') ,if (date_date, concat(' (',date_format(date_date, '%d/%m/%Y'),')') ,'')))) as tit, if(notices_m.notice_id, notices_m.notice_id, notices_s.notice_id) as not_id FROM ((((pret_archive AS oal JOIN (SELECT distinct arc_id_empr FROM pret_archive nbec where (nbec.arc_expl_notice='4647' AND nbec.arc_expl_bulletin='0') AND nbec.arc_id_empr !=0) as nbec ON (oal.arc_id_empr=nbec.arc_id_empr and oal.arc_id_empr!=0 and nbec.arc_id_empr!=0)) LEFT JOIN notices AS notices_m ON arc_expl_notice = notices_m.notice_id ) LEFT JOIN bulletins ON arc_expl_bulletin = bulletins.bulletin_id) LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id) WHERE date_add(oal.arc_fin, INTERVAL 1 day)>=sysdate() AND oal.arc_expl_notice!=4647 AND oal.arc_id_empr !=0 GROUP BY oal.arc_expl_notice, oal.arc_expl_bulletin HAVING total_prets>=1 ORDER BY rand()