// remove suffix "AND " int the end of the WHERE clause query = query.substring(0, query.lastIndexOf("AND"));