title: Combine Multiple Select Count Queries on same table
body: <p>I have a table with a bunch of order rows in it.  I need to check the table to see if there's 1 or more rows matching 2 WHERE clauses.  If there is, I set a variable to 'yes' that I use elsewhere on the page.</p>
  
  <p>Currently I'm checking this with individual php mysql queries but wondering if it's possible to combine them into a single select query so i'm hitting the database one time rather than like 10 or more times. </p>
  
  <p>Here's an example of the current code:</p>
  
  <pre><code>$query9 = "SELECT COUNT(*) as num FROM mojave_requests where status = 'Pending' AND local = 'L-BKED'";
  $requestEDI = mysql_fetch_array(mysql_query($query9));
  $requestEDI = $requestEDI[num];
  if ($requestEDI&gt; 0) {
  $requestsEDI = 'yes';
  }
  
  $query11 = "SELECT COUNT(*) as num FROM mojave_requests where status = 'Pending' AND local = 'LOQ53'";
  $requestLOQ53 = mysql_fetch_array(mysql_query($query11));
  $requestLOQ53 = $requestLOQ53[num];
  if ($requestLOQ53 &gt; 0) {
  $requestsLOQ53 = 'yes';
  }
  
  $query13 = "SELECT COUNT(*) as num FROM mojave_requests where status = 'Pending' AND local = 'L-YRYR'";
  $requestLYRYR = mysql_fetch_array(mysql_query($query13));
  $requestLYRYR = $requestLYRYR[num];
  if ($requestLYRYR &gt; 0) {
  $requestsLYRYR = 'yes';
  }
  
  $query15 = "SELECT COUNT(*) as num FROM mojave_requests where status = 'Pending' AND local = 'L-CAL0611'";
  $requestLCAL0611 = mysql_fetch_array(mysql_query($query15));
  $requestLCAL0611 = $requestLCAL0611[num];
  if ($requestLCAL0611 &gt; 0) {
  $requestsLCAL0611 = 'yes';
  }
  </code></pre>
  
  <p>The only two things different between each query is the "local" column string I'm checking and the variable name I set to "Yes" if there's at least 1 match.</p>
  
  <p>Thanks for looking.</p>