Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql Postgres json选择_Postgresql - Fatal编程技术网

Postgresql Postgres json选择

Postgresql Postgres json选择,postgresql,Postgresql,假设我的应用程序收到了一条传入的JSON消息: { line_nbr : 1, value: 10 }, { line_nbr : 2, value: 30 }, ] 是否可以在postgres中执行以下选择: SELECT JsonObject.value, qty from table_x where id in JsonObject

假设我的应用程序收到了一条传入的JSON消息:

      {
        line_nbr : 1,
        value: 10
       },   

           {
        line_nbr : 2,
        value: 30
       },   

   ]
是否可以在postgres中执行以下选择:

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


换句话说,在传入的JSON对象上加入

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
查看详情