From: | Jeff Janes <jeff(dot)janes(at)gmail(dot)com> |
---|---|
To: | "Armand Pirvu (home)" <armand(dot)pirvu(at)gmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: store key name pattern search |
Date: | 2017-04-04 17:42:23 |
Message-ID: | CAMkU=1x7kejThEr9yrAmxbJDU2bwpJ_2K1eUOoRMgmEi3oBksg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Apr 4, 2017 at 8:41 AM, Armand Pirvu (home) <armand(dot)pirvu(at)gmail(dot)com>
wrote:
> Hi
>
> I have the following case
>
>
> select * from foo;
> col1
> ------------------------------------------------------------
> ---------------------
> "show_id"=>"1", "group_id"=>"32", "group_name"=>"slb",
> "group_add_by"=>"557651"
> "show_id"=>"2", "group_id"=>"33", "group_name"=>"slc",
> "item_add_by"=>"557652"
> (2 rows)
>
> Is there anyway I can do a pattern search by hstore key name something like
>
> select * from foo where skeys(col1) like '%add_by%';
>
> I looked on the doc but did not see anything , or did I miss it ?
>
select * from foo where array_to_string(akeys(x),';') like '%add\_by%';
Note that I back-slashed the underscore, otherwise it acts as a wildcard
and may match more than you bargained for.
Cheers,
Jeff
From | Date | Subject | |
---|---|---|---|
Next Message | Armand Pirvu (home) | 2017-04-04 21:10:04 | Re: store key name pattern search |
Previous Message | Scott Marlowe | 2017-04-04 17:18:04 | Re: WAL being written during SELECT * query |