I had a table with 20k products. In this table I had a jSON column which contained several information about the product. I had to add a new column by a requirement of my boss which will contain the model name (which is inside the jSON). How can I do it? My table product has id = id of the product product_description = jSON with many details about the product and now a new column model_name which my boss wants available outside the jSON
I usually did this query:
SELECT "productInfo"->'product_info'->>'model_name' AS model_name FROM inv.product WHERE id = 1
to obtain the model_name
I want to update all the products so the model_name is now in the new column model_name but i couldn't do it because i'm not familiar with mass updates.
What i want to do in words is:
UPDATE inv.product SET model_name = ( QUERY TO SELECT THE VALUE OF THE model_name ) FOR EACH ROW