I'm starting with postgreSQL and NodeJS and I have a table of office objects with the fields object_id(PK), inventory(varchar), area(FK) and description(text). This table must be updated weekly. How do I update the row according to the corresponding inventory value? That is, if the inventory(varchar) value of a row corresponds to the inventory(varchar) value of one of the new entries then update that row with the values of that entry. Is there a way to do it in one query?
The inventory(varchar) field is unique for each row. For the queries I am using the modules "pg" and "pg-format".
Thank you so much.
I have tried to do it one by one but the table has 6000 rows. I don't know if there is a better way to do it.
you can use the UPDATE statement. Here's an example of how you can update all rows in a table
The WHERE clause is optional. If you omit it, the update will be applied to all rows in the table. If you specify a condition, the update will be limited to the rows that match that condition.
for example: