title: Count num_rows base on field value
body: <p>*The actual problem is quite more complex than the post title :S</p>
  
  <p>Suppose I have table</p>
  
  <pre><code>ID | vote_id |  vote_type |  vote_user
  
  1  ----  2  -----   up -------    Tom
  2  ----  3  -----   up -------    John
  3  ----  3  -----   down -----    Harry
  4  ----  4  -----   up -------    Tom
  5  ----  2  -----   down -----    John
  6  ----  3  -----   down -----    Tom
  </code></pre>
  
  <p>So what I want to do is</p>
  
  <ol>
  <li>Query the table by specific <strong>vote_id</strong></li>
  <li>Then Count how many voted <strong>up</strong> and how many voted <strong>down</strong> from the query in 1</li>
  <li>Then I want to check also that had <strong>John</strong> voted for that vote_id or not.</li>
  </ol>
  
  <p>And the way I do is.</p>
  
  <pre><code>$up=0;
  $down=0;
  $voted="no"; 
  $r=mysql_query("SELECT*FROM table_name WHERE vote_id == 3");
  
   while($row=mysql_fetch_array($r){
     if($row["vote_type"]=="up"){ $up++;}else{$down++;}
     if($row["vote_user"=="John"){ $voted="yes";}
   }
  </code></pre>
  
  <p><strong>But is there a way ( equivalent code ) to do this without using WHILE LOOP</strong> because the actual table can be very large so running while loop can be very exhaustive :S</p>
  
  <p><strong>EDIT</strong>  Can I do with single query?</p>