Fixed a mistake with the ID generation query.