--Raghav
On Sun, Jun 24, 2012 at 3:45 AM, Joe Van Dyk <joe@xxxxxxxxx> wrote:
On Sat, Jun 23, 2012 at 3:03 PM, Joe Van Dyk <joe@xxxxxxxxx> wrote:This is the best I can come up with:
> 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@xxxxxxxxx","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@xxxxxxxxx',
> 'joevandyk');
select row_to_json(f) from (select email_address, username from users) f;
Is there a cleaner way to do this?
--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general