title: How do I put an 'if clause' in an SQL string?
body: <p>So here's what I want to do on my <em>MySQL</em> database.</p>
  
  <p>I would like to do:</p>
  
  <pre><code>SELECT *
      FROM itemsOrdered
      WHERE purchaseOrder_ID = '@purchaseOrdered_ID'
          AND status = 'PENDING'
  </code></pre>
  
  <p>If that would not return any rows, which is possible through <code>if(dr.HasRows == false)</code>, I would now create an <code>UPDATE</code> in the <code>purchaseOrder</code> database:</p>
  
  <pre><code>UPDATE purchaseOrder
      SET purchaseOrder_status = 'COMPLETED'
      WHERE purchaseOrder_ID = '@purchaseOrder_ID'
  </code></pre>
  
  <p>How would I be able to make this process a little shorter?</p>