Si myslím, že nemůžeš kombibovat SELECT id a MAX(id). Já bych tam nechal jen to MAX(id). To už musí chodit.