sql check if record exists before update