title: How to count the columns of a MySQL query when the number of columns returned is dynamic?
body: <p>Is it possible to retrieve the count of the number of columns a query returns? This can be easily done with a bound scripting language such as php, but I'm looking for db only solution.</p>
  
  <p>Example:</p>
  
  <pre><code>CountCols(SELECT 'a','b','c')
      =&gt; 3
  CountCols(SELECT * FROM information_schema.session_variables)
      =&gt; 2
  </code></pre>