I have a column in my mysql table called download_count of type int.
Now I want to use update_all to update some fields with some values, but also increment the download_count along with it.
I have tried the following syntax:
find_record.update_all(username: username, download_date: download_date, "download_count= download_count + 1")
But I beleive the above acts like a where clause. So the download_count does not get updated. I want the username, download_date and the download_count to be updated by the above query.
Can someone point me to the correct syntax?
Try
find_record.update_all(["username=?, download_date=?, download_count=download_count+1", username, download_date])
Second argument to update_all
is a condition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With