Upsert question

I'm retrieving orders every 30 minutes that may be the same or some may be updated so I want the row to just update with the new information but I don't know how to do that, in the docs it only shows updating all the rows with a set value. Is there a way to update each row with the new data? I've attached an image to give an understanding of what im wanting
No description
4 Replies
Angelelz
Angelelz15mo ago
Looks like formattedOrders is an array?
Angelelz
Angelelz15mo ago
PostgreSQL Documentation
INSERT
INSERT INSERT — create new rows in a table Synopsis [ WITH [ RECURSIVE ] with_query [, ...] ] INSERT …
Angelelz
Angelelz15mo ago
The SET and WHERE clauses in ON CONFLICT DO UPDATE have access to the existing row using the table's name (or an alias), and to the row proposed for insertion using the special excluded table.
So you have access the old value in the row with the table name, and to to the row being inserted with the excluded keyword. Take a look at this link for an example: https://discord.com/channels/1043890932593987624/1149847252060352522/1150934123268018246
Demnu
DemnuOP14mo ago
thats perfect thankyou mate!
Want results from more Discord servers?
Add your server