how update field using other fields in single query ?
sql:
"update table_name set field1=fields2 + 1 id=123"
tried these things, didn't work
model.update(123, :field => "field2 + 1") model.update(123, :field => :field2 + 1) model.update(123, "field = field2 + 1")
don't want in 2 query.
model.update_all("field = field2 + 1", {:id => 123})
the second argument conditions, on update should happen
Comments
Post a Comment