how to search key in jsonb type column in postgresql

Posted on

Question :

I have a column in PostgreSQL with jsonb datatype. I need to check one key whether it exists in that column or not by executing query.

Answer :

To find all the rows in a table where the data column contains the key mykey on the top level, use

SELECT * FROM mytable
WHERE data ? 'mykey';

Leave a Reply

Your email address will not be published. Required fields are marked *