title: mysql don't count row twice if column data is duplicated
body: <p>I am counting the rows in a mysql table called <code>ptb_profile_views</code>.</p>
  
  <p>My table looks like this:</p>
  
  <pre><code>id  |  profile_id   | viewed_profile_id  |  date_time  |
  
  1          1                  6              
  2          2                  6
  3          2                  6
  4          2                  6
  5          3                  6
  </code></pre>
  
  <p>At the moment my query counts all the rows in the table. However, I only want it to count the rows which do not contain duplicate values in <code>profile_id</code>.</p>
  
  <p>So if user 2/profile_id 2 views user 6's profile several times, which in this case they do, I only want the query to count it once. I am trying to use distinct but its not working. Can someone please show me where I'm going wrong?</p>
  
  <pre><code>function check_profile_views() {
      global $connection;
      global $_SESSION;
      $query = "SELECT DISTINCT COUNT(id) FROM ptb_profile_views WHERE viewed_profile_id=".$_SESSION['user_id']." AND profile_id='0'";
      $check_profile_views_set = mysql_query($query, $connection);
      confirm_query($check_profile_views_set);
      return $check_profile_views_set;        
  }
  </code></pre>