Обсуждение: selecting from integer[]
select * from pg_user where usesysid=(select grolist[1] from pg_group where groname='mygroup'); select * from pg_user where usesysid=(select grolist[2] from pg_group where groname='mygroup'); select * from pg_user where usesysid=(select grolist[3] from pg_group where groname='mygroup'); Can those three queries be merged to one query? (and still gives me those three rows) Or do I have to explicitly say grolist[1], grolist[2], etc.... Thanks in advance :)
Well, you can always just UNION them - I don't know if there's a better way tho. select * from ... union [all] select * from ... union [all] select * from ...; Chris On Sat, 29 Jun 2002, Kelly wrote: > > select * from pg_user where usesysid=(select grolist[1] from pg_group > where groname='mygroup'); > select * from pg_user where usesysid=(select grolist[2] from pg_group > where groname='mygroup'); > select * from pg_user where usesysid=(select grolist[3] from pg_group > where groname='mygroup'); > > Can those three queries be merged to one query? (and still gives me > those three rows) > Or do I have to explicitly say grolist[1], grolist[2], etc.... > > Thanks in advance :) > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > >
On Sat, 29 Jun 2002, Kelly wrote: > select * from pg_user where usesysid=(select grolist[1] from pg_group > where groname='mygroup'); > select * from pg_user where usesysid=(select grolist[2] from pg_group > where groname='mygroup'); > select * from pg_user where usesysid=(select grolist[3] from pg_group > where groname='mygroup'); > > Can those three queries be merged to one query? (and still gives me > those three rows) > Or do I have to explicitly say grolist[1], grolist[2], etc.... If you want to do "is element in array," I believe the array iterator functions in contrib/array might help you.