Fix bug on SQL update