fix db query condition bug