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 '&& baselistaatp.listatp = (select max(b2.listatp) from baselistaatp b2) ORDE' at line 5