SELECT * FROM ((SELECT * FROM ((SELECT * FROM ((SELECT outstandings.target,outstandings.idOutstanding,outstandings.idType,outstandings.outOrder,events.idEvent as idRel,events.name_100,events.brief_100,events.link,events.content_100, outstandings.inhome FROM outstandings INNER JOIN events ON outstandings.idRel=events.idEvent WHERE outstandings.idType=1 AND outstandings.active=1 AND outstandings.idSpace=2 AND (outstandings.publishStart<=STR_TO_DATE("21/11/2024","%d/%m/%Y") AND outstandings.publishEnd>=STR_TO_DATE("21/11/2024","%d/%m/%Y"))) UNION (SELECT outstandings.target,outstandings.idOutstanding,outstandings.idType,outstandings.outOrder,articles.idArticle as idRel,articles.name_100,articles.brief_100,articles.originalSource as link,articles.content_100, outstandings.inhome FROM outstandings INNER JOIN articles ON outstandings.idRel=articles.idArticle WHERE outstandings.idType=2 AND outstandings.active=1 AND outstandings.idSpace=2 AND (outstandings.publishStart<=STR_TO_DATE("21/11/2024","%d/%m/%Y") AND outstandings.publishEnd>=STR_TO_DATE("21/11/2024","%d/%m/%Y")))) TABLA ) UNION (SELECT outstandings.target,outstandings.idOutstanding,outstandings.idType,outstandings.outOrder,activities.idActivity as idRel,activities.name_100,activities.brief_100,activities.link,activities.content_100, outstandings.inhome FROM outstandings INNER JOIN activities ON outstandings.idRel=activities.idActivity WHERE outstandings.idType=3 AND outstandings.active=1 AND outstandings.idSpace=2 AND (outstandings.publishStart<=STR_TO_DATE("21/11/2024","%d/%m/%Y") AND outstandings.publishEnd>=STR_TO_DATE("21/11/2024","%d/%m/%Y")))) TABLA2) UNION (SELECT outstandings.target,outstandings.idOutstanding,outstandings.idType,outstandings.outOrder,texts.idText as idRel,texts.name_100,texts.brief_100,texts.link,texts.content_100, outstandings.inhome FROM outstandings INNER JOIN texts ON outstandings.idRel=texts.idText WHERE outstandings.idType=4 AND outstandings.active=1 AND outstandings.idSpace=2 AND (outstandings.publishStart<=STR_TO_DATE("21/11/2024","%d/%m/%Y") AND outstandings.publishEnd>=STR_TO_DATE("21/11/2024","%d/%m/%Y")))) TABLA3 order by outOrder 0