0

I have a table

CREATE TABLE table_a
(
  id bigint NOT NULL,
  name json,
  CONSTRAINT table_a_pkey PRIMARY KEY (id)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE table_a
  OWNER TO postgres;

Data in the table:

1;"{"ru":"Название","en":"Name"}"
2;"{"ru":"Название","en":"Name"}"

When I trying select the name

SELECT id, name->'en'::text as name from table_a;

have next results:

1;""Name""
2;""Name""

How I can select data without quotes?

Thanks!

1 Answer 1

4

The -> operator returns JSON. Try using ->> operator - it returns varchar. Something like:

SELECT id, name->>'en'::text as name from table_a;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.