Answer the question
In order to leave comments, you need to log in
Is it possible to make such a condition for the selection or do I need a separate column?
There is a table in which the item column contains an object in which there is an id field.
Is it possible to make a condition that would compare the id value from this column? Something like this
. I think that you can’t do this, because in essence you need to first get the value of the item column, and then compare (this will affect performance), maybe I'm wrong.
If you can't directly compare values, then what query can add a new column to a table with id values from an object?
SELECT item FROM items WHERE item.id = 123
Answer the question
In order to leave comments, you need to log in
Everything is possible, especially if you first read the docs https://www.postgresql.org/docs/12/functions-json.html
And so that there is no "this will affect performance", you can even hang an index on this part of json.
And besides this, it is better to use the type not json, but jsonb
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question