title: MySQL - Select from multiple tables and display multiple fields
body: <p>I have a WordPress multisite with 100 <code>*_options</code> tables namely <code>WPM_101_options</code> to <code>WPM_201_options</code>.</p>
  <p>I am trying to query option names <code>admin_email</code>, <code>siteurl</code> and <code>blogname</code>.</p>
  <p>This code will work on 1 table:</p>
  <pre><code>SELECT option_name, option_value 
  FROM wpm_104_options
  WHERE option_name = 'admin_email' 
  UNION
  SELECT option_name, option_value 
  FROM wpm_104_options
  WHERE option_name = 'siteurl'
  UNION
  SELECT option_name, option_value 
  FROM wpm_104_options
  WHERE option_name = 'blogname'
  
  
  </code></pre>
  <p>But how do I get it working with multiple tables?
  I tried 2 tables with...</p>
  <pre><code>SELECT option_name, option_value 
  FROM wpm_104_options,wpm_105_options
  WHERE option_name = 'admin_email' 
  UNION
  SELECT option_name, option_value 
  FROM wpm_104_options,wpm_105_options
  WHERE option_name = 'siteurl'
  UNION
  SELECT option_name, option_value 
  FROM wpm_104_options,wpm_105_options
  WHERE option_name = 'blogname'
  
  </code></pre>
  <p>and</p>
  <pre><code>SELECT option_name, option_value 
  FROM wpm_104_options,wpm_101_options
  WHERE option_name = 'admin_email' 
  GROUP BY option_name
  UNION
  SELECT option_name, option_value 
  FROM wpm_104_options,wpm_101_options
  WHERE option_name = 'siteurl'
  GROUP BY option_name
  UNION
  SELECT option_name, option_value 
  FROM wpm_104_options,wpm_101_options
  WHERE option_name = 'blogname'
  GROUP BY option_name
  </code></pre>
  <p>and</p>
  <pre><code>SELECT wpm_104_options.option_name as n104, wpm_104_options.option_value as v104, wpm_101_options.option_name as n101, wpm_101_options.option_value as v101
  FROM wpm_104_options, wpm_101_options
  WHERE option_name = 'admin_email' 
  </code></pre>
  <p>...but I get an error:</p>
  <blockquote>
  <p>Error Code: 1052. Column 'option_name' in field list is ambiguous 0.000 sec</p>
  </blockquote>