<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>okashoi</author_name>
  <author_url>https://blog.hatena.ne.jp/okashoi/</author_url>
  <blog_title>s平面の左側</blog_title>
  <blog_url>https://blog.okashoi.net/</blog_url>
  <categories>
    <anon>技術／その他</anon>
  </categories>
  <description>www.postgresql.jp \gset には 1 行の結果をしか格納できないが、string_aggr を使ってカンマ区切り文字列にし、string_to_array で展開して使うという工夫で次のように使用できる。 -- 普通の変数代入 \set target_user_id '01234567-89ab-cdef-0123-456789abcdef' -- SELECT 結果を \gset を 使って post_ids という名前で格納 SELECT string_agg(id::text, ',') as post_ids FROM post WHERE auther_id = …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.okashoi.net%2Fentry%2F2025%2F07%2F17%2F183055&quot; title=&quot;【PostgreSQL】SELECT した結果を変数に格納して後続のクエリで利用する（\gset メタコマンド） - s平面の左側&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2025-07-17 18:30:55</published>
  <title>【PostgreSQL】SELECT した結果を変数に格納して後続のクエリで利用する（\gset メタコマンド）</title>
  <type>rich</type>
  <url>https://blog.okashoi.net/entry/2025/07/17/183055</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
