Rechercher dans le manuel MySQL
20.3.4.3 Update Tables
You can use the update()
method to modify one
or more records in a table. The update()
method works by filtering a query to include only the records to
be updated and then applying the operations you specify to those
records.
To replace a city name in the city table, pass to the
set()
method the new city name. Then, pass to
the where()
method the city name to locate
and replace. The following example replaces the city Peking with
Beijing.
mysql-js> db.city.update().set("Name", "Beijing").where("Name = 'Peking'")
Query OK, 1 item affected (0.04 sec)
Use the select()
method to verify the change.
mysql-js> db.city.select(["ID", "Name", "CountryCode", "District", "Info"]).where("Name = 'Beijing'")
+------+-----------+-------------+----------+-----------------------------+
| ID | Name | CountryCode | District | Info |
+------+-----------+-------------+----------+-----------------------------+
| 1891 | Beijing | CHN | Peking | {"Population": 7472000} |
+------+-----------+-------------+----------+-----------------------------+
1 row in set (0.00 sec)
Related Information
See TableUpdateFunction for the full syntax definition.
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-mysql-shell-tutorial-javascript-table-update.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.