Fix sql for updating