Fix SQL bug during data update.