Say I have in Postgres stored in JSON field called “data” like this
{
"CUSTA": {
"name": "Customer A",
},
"CUSTB": {
"name": "Customer B",
},
"CUSTC": {
"name": "Customer C",
}
}
How can I query to return the record that contains the key “CUSTA” ? or even better the value of “CUSTA” which is "name": "Customer A"
trying to do something like this but obviously i cant use the keyword key
SELECT * FROM invoices WHERE data->>key = 'CUSTA';