select a.ID, a.LAT from pase2page p2p JOIN APASE a on p2p.pase=a.ID where p2p.page='14' and a.ID not in () group by p2p.pase order by a.DATUMS desc , a.ID desc limit 3, 3You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') group by p2p.pase order by a.DATUMS desc , a.ID desc limit 3, 3' at line 1