((SELECT *,e.id as id_foto_ok FROM cataloghi_foto as e
LEFT JOIN foto_aggiuntive as b on e.id = b.id_foto
LEFT JOIN prodotto as c on c.id_foto = e.id
WHERE c.id_azienda = '1'
AND e.tipo_prod = '1'
AND b.ordine = (SELECT MIN(ordine) from foto_aggiuntive as d WHERE d.id_foto = b.id_foto)
AND e.se_attivo = '1'
AND e.data_da >= CURDATE()
AND MONTH(e.data_da) = '08'
ORDER BY e.data_da,e.id ASC
LIMIT 1000,1000) UNION
(SELECT *,e.id as id_foto_ok FROM cataloghi_foto as e
LEFT JOIN foto_aggiuntive as b on e.id = b.id_foto
LEFT JOIN prodotto as c on c.id_foto = e.id
WHERE c.id_azienda = '1'
AND e.tipo_prod = '1'
AND b.ordine = (SELECT MIN(ordine) from foto_aggiuntive as d WHERE d.id_foto = b.id_foto)
AND e.se_attivo = '1'
AND e.se_cs = '1'
AND e.mese_cs = '8'
ORDER BY e.mese_cs ASC)) ORDER BY data_da,se_cs ASC