title: Number of different records (rows) in a table
body: <p>quite often I have to count then number of different records in a table. However, in MySQL neither</p>
  
  <pre><code>select count(distinct *) from t;
  </code></pre>
  
  <p>nor</p>
  
  <pre><code>select count(distinct t.*) from t;
  </code></pre>
  
  <p>work. I know that I can work around that by</p>
  
  <pre><code>select count(*) as countdistinctrows
  from (
    select distinct * from t
  ) x;
  </code></pre>
  
  <p>but this is ugly. Is there really no way do ask for the number of distinct rows? By the way,</p>
  
  <pre><code>select distinct count(*) from t;
  </code></pre>
  
  <p>is not the answer since then distinct is applied to the number of rows in the table and thus gives the same as</p>
  
  <pre><code>select count(*) from t;
  </code></pre>