FOUT:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT DISTINCT G.iMessageNbr, G.iUserNbr, G.iUserLevel, G.dMessageDat' at line 5 SQL = SELECT DISTINCT G.iMessageNbr, G.iUserNbr, G.iUserLevel, G.dMessageDate, G.cMessage, U.cUserNickname, U.cUserEmail, T.cTypeDescription FROM guestbook G LEFT OUTER JOIN user U ON (U.iUserNbr = G.iUserNbr), type T WHERE T.iTypeNbr = G.iUserLevel AND G.iUserNbr = UNION SELECT DISTINCT G.iMessageNbr, G.iUserNbr, G.iUserLevel, G.dMessageDate, G.cMessage, U.cUserNickname, U.cUserEmail, T.cTypeDescription FROM guestbook G LEFT OUTER JOIN user U ON (U.iUserNbr = G.iUserNbr), type T WHERE T.iTypeNbr = G.iUserLevel AND G.iUserLevel <= order by dMessageDate desc, iMessageNbr desc