Sql updating multiple rows
select count from update likes set gmt_modified = now(), count = count 1 where object_id = ？; It is important to note that the enhanced syntax is not expressly stated in the cloud database document.
Therefore, we'd better consult relevant experts before applying it to the production environment.
So that's the deal, for the sake of user experience!
Well, the user experience is really a useful imperial sword.
Why is business logic involved so gratuitously by increasing the number by one?
Shouldn’t the back-end server be responsible for representation of the data on the front-end server?
If you are using Alibaba Cloud RDS, you may try the writing to combine the update and select statements into an SQL statement, and further reduce the network overhead and database overhead to improve the performance.
When the problem was posted, there was no way to have it done via a single query in My SQL.
Even until now, there is still no way to have it done via a single query in the Oracle-maintained official version of My SQL. Besides the Maria DB which has been thoroughly split out, there is also Percona, the so-called enhanced version which is fully compatible with My SQL.
The gmt_xxx contains the record creation and update time without business meaning.
The object_id is the primary key of the object that can be liked, which is equivalent to an external key, but the data consistency of association tables will be guaranteed by the application logic, and it will not be aware of the database; the count field records the number of likes of this object.