SELECT i.*, (SELECT url FROM trc_fotos WHERE estado=3 AND idPagina=i.id ORDER BY RAND() LIMIT 0,1) AS afoto FROM trc_paginas i WHERE id=