comalex3
comalex3

Reputation: 2606

Update table field with data from JSON field

I have table order with fields sku, asin and json field raw with some json data there like:

{
   "user_sku": "123",
   "asin": "213213",
}

Is that possible to update order.sku with data from order.raw.user_sku in one sql query?

Upvotes: 0

Views: 95

Answers (1)

user330315
user330315

Reputation:

That looks like a simple UPDATE

update "order"
   set sku = raw ->> 'user_sku';

The ->> operator gets the value for the specified key from the JSON value.

Upvotes: 2

Related Questions