问题
We are storing dynamic json data to a postgresql jsonb
datatype field. Most of the json keys are dynamic and nested.
Now I need to search one particular value inside this json data field. This value may be present with any key name.
row1
= { "header": { "piecesids" : [100,200,300] }, "footer" : {"pieceids" : [500,300]} }
row2
= { "header_right": { "piecesids" : [500,300,400] }, "footer_left" : {"pieceids" : [300,200]} }
row3
= { "body_right": { "piecesids" : [500,300,600] }, "body_left" : {"pieceids" : [300]} }
I need all the rows where pieceid
200 is present that means I want row1 & row2
to be returned.
I have gone through several blogs, but all mentions how we can search by key but not by value.
来源:https://stackoverflow.com/questions/43252423/searching-for-a-particular-value-in-a-jsonb-datatype-prostgresql