error=select *, p.producator as producer, c.categorie as category, foto.nume_foto as fnume, foto.tbn, foto.foto_id as fid, o.id as pid, o.stoc_val stoc, o.pret_brut, o.pret_vechi, o.pret_net from oferte o join categorii c on o.categorie=c.categorie_id left join producatori p on o.producator=p.producator_id -- and p.inactiv=0 join oferte_promovate op on o.id=op.oferta_id join zone on zone.zona_id=op.zona_id left join ( select foto.* from (select min(foto_id) mx, id from foto group by id) ult join foto on ult.mx=foto.foto_id ) foto on o.id=foto.id where zone.zona_id= and o.pret_brut>0 and CURDATE() <= op.panala ORDER BY op.`ord`