0

Let's say that I have an incoming JSON message to my app:

      {
        line_nbr : 1,
        value: 10
       },   

           {
        line_nbr : 2,
        value: 30
       },   

   ]

Is it possible to perform the following selection in postgres :

SELECT  JsonObject.value, qty   from table_x  where id in  JsonObjects.line_nbr 


In other words join on the incoming JSON object

1 Answer 1

1
with your_js as (
 select (value->>'line_nbr')::int as line_nbr
 from jsonb_array_elements('JsonObjects'::jsonb) as je
)
select line_nbr, qty
from table_x
 join your_js on line_nbr = table_x.id

check here for detail

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.