Fixed query for admin to prevent SQL exception.