SELECT a.ID, a.mediaType, a.Perc,a.Link, a.Insert_Date, NULL as Msg, NULL as Color FROM posts as a WHERE a.Perc IS NOT NULL AND a.Active=1 UNION SELECT b.ID, "photo" as mediaType, b.Perc_Img as Perc, NULL as Link, b.Insert_Date, b.Msg, b.Color FROM ringraziamenti as b WHERE b.Active=1 AND !(Perc IS NULL AND Perc_Img IS NULL) ORDER BY Insert_Date DESC LIMIT 20 - Unknown column 'a.Active' in 'where clause'