Conditional UPDATE statement with JOIN
<p>I'm trying to update a column <code>Plan_Status</code> based on the value of another table <code>main</code>, column <code>Days_At_Step</code>.<br> The following statements work, however, how would I structure this as a conditional statement? <br>Or, is there another strategy that I could use?</p>

<p>I feel like there's a better way than using three identical statements with different WHERE conditions.</p>

<pre><code>  UPDATE controlState 
  SET Plan_Status=1 
  FROM controlState JOIN main ON main.Cscc = controlState.Cscc 
  WHERE Days_At_Step &lt; 2;

  UPDATE controlState 
  SET Plan_Status=2 
  FROM controlState JOIN main ON main.Cscc = controlState.Cscc 
  WHERE (Days_At_Step &gt;= 2 OR Days_At_Step &lt; 4);

  UPDATE controlState 
  SET Plan_Status=3 
  FROM controlState JOIN main ON main.Cscc = controlState.Cscc 
  WHERE Days_At_Step &gt; 4;
</code></pre>