5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【PostgreSQL】1:Nのテーブルのカラムを配列で取得する

Last updated at Posted at 2016-04-30

SQL一発で取れるのは良いですね。

SELECT
  id,
  column1,
  column2,
  array(SELECT column3 FROM table2 WHERE table2.table1_id = table1.id) as culumn3
FROM
  table1;
5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?