title: How do I execute the result of a query using the psql client?
body: <p>Using the psql client version 8.4.20, I created this select command that generates a bunch of other select commands:</p>
  
  <pre><code>mydatabase=# select concat('select count(*) from ', table_schema, '.', table_name, ';') from information_schema.tables where table_name like '%stockindex_alias%';
  
  select count(*) from de_de.merged_stockindex_alias_de_de;
  select count(*) from en_us.merged_stockindex_alias_en_us;
  select count(*) from es_la.merged_stockindex_alias_es_la;
  select count(*) from fr_fr.merged_stockindex_alias_fr_fr;
  select count(*) from nl_nl.merged_stockindex_alias_nl_nl;
  select count(*) from pt_br.merged_stockindex_alias_pt_br;
  select count(*) from zh_hk.merged_stockindex_alias_zh_hk;
  </code></pre>
  
  <p>I know I can use \g to store those seven statements into a file, then execute the file with \i.</p>
  
  <p>How can I execute the result of the query (those seven statements) in a single command without the intermediate file?  I've tried \set, EXECUTE, searched the web, but can't get it right.</p>
  
  <p>EDIT: The previous select statements erroneously had the word "table" in them, which I have fixed.</p>