how to search jsonb column in Postgresql ( not nested column )

Jackson Kasi - Aug 30 '22 - - Dev Community

my schema :

create table blog (
  id  SERIAL PRIMARY KEY,
  title varchar,
  tags jsonb
);
Enter fullscreen mode Exit fullscreen mode

my db:
enter image description here

my query:

const tags = "horr";
const query = `SELECT * FROM blog where tags like '%${tags}%'`;
Enter fullscreen mode Exit fullscreen mode

what I am want:

now I am want to get only "tags" column include "horror". but I wanna use just "horr"

I know this query is not work. but wanna do like this bellow

"rows": [
    {
      "id": 1,
      "title": "horror stroy",
      "tags": [
        "sad",
        "horror"
      ]
    }
  ]
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .