Epost-adresser for grupper


query func fail1! groups:(SELECT Email FROM tblperson p LEFT JOIN tblarbeidsforhold a ON a.AF_person_id=p.person_id LEFT join tblgruppemedlemmer gm ON gm.personid=p.person_id WHERE NOT isnull(Email) AND LEFT(Email,1)!='#' AND (isnull(AF_Sluttet_dato) OR AF_Sluttet_dato>curdate()) AND isnull(gmtildato) AND NOT isnull(AF_person_id) AND gm.gruppeid=1014 ) UNION (SELECT Email FROM tblperson p LEFT join tblGjest g ON g.g_person_id=p.person_id LEFT join tblgruppemedlemmer gm ON gm.personid=p.person_id WHERE NOT isnull(Email) AND LEFT(Email,1)!='#' AND (g_tildato='0000-00-00' OR g_tildato>curdate()) AND NOT isnull(g_person_id) AND isnull(gmtildato) AND gm.gruppeid=1014 ) UNION (SELECT Email FROM tblperson p LEFT join tblEkstern e ON e.e_person_id=p.person_id LEFT join tblgruppemedlemmer gm ON gm.personid=p.person_id WHERE NOT isnull(Email) AND LEFT(Email,1)!='#' AND NOT isnull(e_person_id) AND (e_tildato>curdate() OR e_tildato='0000-00-00') AND isnull(gmtildato) AND gm.gruppeid=1014 ) ORDER BY Email