Re: row_to_json question
От | Joe Van Dyk |
---|---|
Тема | Re: row_to_json question |
Дата | |
Msg-id | CACfv+pLGDodRthgTdWOCOQgin2O5KXkn4Pv_EREN2c5MPdKQRw@mail.gmail.com обсуждение исходный текст |
Ответ на | row_to_json question (Joe Van Dyk <joe@tanga.com>) |
Ответы |
Re: row_to_json question
Re: row_to_json question |
Список | pgsql-general |
On Sat, Jun 23, 2012 at 3:03 PM, Joe Van Dyk <joe@tanga.com> wrote: > How can I use row_to_json for a subset of columns in a row? (without > creating a new view or using a CTE?) > > What I want returned: > {"email_address":"joe@tanga.com","username":"joevandyk"} > Note that there is no "id" column in the result. > > > create table users (id serial primary key, email_address varchar, > username varchar); > insert into users (email_address, username) values ('joe@tanga.com', > 'joevandyk'); This is the best I can come up with: select row_to_json(f) from (select email_address, username from users) f; {"email_address":"joe@tanga.com","username":"joevandyk"} Is there a cleaner way to do this?
В списке pgsql-general по дате отправления: