Node.js MySQL UPDATE Table Query

You can update records of a table using MySQL UPDATE Query.

Node.js MySQL Update record(s) of a table

Consider the case that due to manual error, records in the students table are inserted with marks as 74 instead of 84. Now we shall execute a MySQL Update Query that updates marks column with value 84 where there is a value of 74.

Run the above program in Terminal

Node.js MySQL Update all records of a table

Consider a scenario where the exam conducted to the students is cancelled due to some reason, you want to reconduct the exam. So, you would like to update the marks for all the students to 0. Following Node.js MySQL UPDATE Query Example shows how to update all the records of a table.

Observe that there is no WHERE clause in the Query because of which all the records are selected for update process.

Conclusion :

In this Node.js Tutorial – Node.js MySQL – UPDATE Table Query, we have learnt to UPDATE records based on a condition or UPDATE all the records of a table.