O
O
Oklick2016-12-23 02:05:16
PostgreSQL
Oklick, 2016-12-23 02:05:16

How to get records where params ->> 'price' is greater than a given number in PostgreSQL(jsonb)?

Good day. There are a bunch of records stored in the PostgreSQL melon database. Inside the params field (jsonb format) is the price parameter. How can I arrange a query to pull out only those fields in which price >= 1000.
Here is an example of what lies inside the params field:

{"new": "0", "sale": "1", "brand": "1", "color": ["1"], "price": "1465 ", "material": ["1"], "sale_num": "50", "sale_type": "1"}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oklick, 2016-12-23
@Oklick

found the answer myself.
CAST( params ->> 'price' as integer ) >= 1000

E
Eugene Wolf, 2016-12-23
@Wolfnsex

Isn't that what you're looking for?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question