pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
union in subselect? 2+ messages / 2 participants [nested] [flat]
* union in subselect? @ 2001-07-31 14:42 Gary Stainburn <gary.stainburn@ringways.co.uk> 0 siblings, 1 reply; 2+ messages in thread From: Gary Stainburn @ 2001-07-31 14:42 UTC (permalink / raw) To: pgsql-sql Hi all, Can you use (or work around towards) a union in a subquery? I have :- Members mid int4; mnec bool; -- many NEC members Positions (one position = one holder - excludes NEC) posn char(4); pholder int4; -- refers to mid Actions caction char(4) -- e.g. UPDT = update team cposn char(4) -- refers to posn clevle int4 -- increasing permission level select 'NEC' as posn from members where mid = 81 and mnec = true; posn ------ NEC (1 row) select posn from positions where pholder = 81; posn ------ MSEC ITA REG (3 rows) select posn from positions where pholder = 81 union select 'NEC' as posn from members where mnec = true and mid = 81; posn ------ ITA MSEC NEC REG (4 rows) So far so good. select * from actions where cposn in (select posn from positions where pholder = 81); caction | cposn | clevel ---------+-------+-------- ENQT | REG | 2 ENQM | REG | 2 AMET | REG | 2 AMET | ITA | 3 Still works - looking good select * from actions where cposn in (select posn from positions where pholder = 81 union select 'NEC' as posn from members where mnec = true and mid = 81); gives me: ERROR: parser: parse error at or near "union" -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: union in subselect? @ 2001-07-31 15:16 Tom Lane <tgl@sss.pgh.pa.us> parent: Gary Stainburn <gary.stainburn@ringways.co.uk> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2001-07-31 15:16 UTC (permalink / raw) To: Gary Stainburn <gary.stainburn@ringways.co.uk>; +Cc: pgsql-sql Gary Stainburn <gary.stainburn@ringways.co.uk> writes: > select * from actions where cposn in (select posn from positions where pholder > = 81 union select 'NEC' as posn from members where mnec = true and mid = 81); > gives me: > ERROR: parser: parse error at or near "union" Update to PG 7.1. regards, tom lane ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-07-31 15:16 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2001-07-31 14:42 union in subselect? Gary Stainburn <gary.stainburn@ringways.co.uk> 2001-07-31 15:16 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox