pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Alexander Farber <alexander.farber@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: SELECT UNION into a text[]
Date: Wed, 10 Oct 2018 09:29:14 +0100
Message-ID: <87sh1e8aw4.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <CAKFQuwae8OoiPCC5+ryJ_k3R_-UrTOnWQS6O3JBQ6C3ieJpj5w@mail.gmail.com>
References: <CAADeyWhfGB8QAox+HFaFPBkmtk5Zx1FRVLOqvASS7=VuitpANA@mail.gmail.com>
	<CAKFQuwae8OoiPCC5+ryJ_k3R_-UrTOnWQS6O3JBQ6C3ieJpj5w@mail.gmail.com>

>>>>> "David" == David G Johnston <david.g.johnston@gmail.com> writes:

 >> SELECT ARRAY_AGG(hashed)
 >> FROM words_nouns
 >> WHERE added > TO_TIMESTAMP(1539100913)
 >> UNION
 >> SELECT ARRAY_AGG(hashed)
 >> FROM words_verbs
 >> WHERE added > TO_TIMESTAMP(1539100913);

 David> SELECT array_agg(words) FROM (
 David> SELECT hashed FROM words_nouns
 David> UNION ALL
 David> SELECT hashed FROM words_verbs
 David> ) AS src

Or even better,

SELECT ARRAY(SELECT hashed FROM words_nouns
             UNION
             SELECT hashed FROM words_verbs);

-- 
Andrew (irc:RhodiumToad)




view thread (3+ messages)

Message-ID: <87sh1e8aw4.fsf@news-spur.riddles.org.uk>
Permalink:  ../87sh1e8aw4.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87sh1e8aw4.fsf@news-spur.riddles.org.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, david.g.johnston@gmail.com, alexander.farber@gmail.com
  Subject: Re: SELECT UNION into a text[]
  In-Reply-To: <87sh1e8aw4.fsf@news-spur.riddles.org.uk>
  References: <CAADeyWhfGB8QAox+HFaFPBkmtk5Zx1FRVLOqvASS7=VuitpANA@mail.gmail.com> <CAKFQuwae8OoiPCC5+ryJ_k3R_-UrTOnWQS6O3JBQ6C3ieJpj5w@mail.gmail.com> <87sh1e8aw4.fsf@news-spur.riddles.org.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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