Add AND option on getnextid