title: Toggle bit for a series of rows based on single row in SQLite
body: <p>I have a table containing rows which are either 'headers' or 'normal', non-header entries. This is tracked by an <code>INTEGER</code> affinity column <code>IsHeader</code>.</p>
  
  <p>Likewise, I have a column tracking if the row is 'Active'.</p>
  
  <p>With a table 'Entries', and another column 'MCL_Row' used to find relevant rows, I can toggle the value of 'Active' using </p>
  
  <pre><code>UPDATE Entries SET(Active) = 
      (SELECT (~(Active&amp;1))&amp;(Active|1) WHERE MCL_Row = &lt;target&gt;) 
      WHERE MCL_Row = &lt;target&gt;;
  </code></pre>
  
  <p>This works, but if I want to toggle an entire group on or off based on the header, I can't use</p>
  
  <pre><code>UPDATE Entries SET(Active) = 
      (SELECT (~(Active&amp;1))&amp;(Active|1) WHERE S_Type = &lt;typenum&gt; AND IsHeader=1)
      WHERE S_Type = &lt;typenum&gt;;
  </code></pre>
  
  <p>because here, the SELECT subquery returns the one value I want, but multiple rows are updated. As a result, the first row gets the correct result, and subsequent rows satisfying the <code>WHERE S_Type = &lt;typenum&gt;</code> clause are updated with a <code>NULL</code> value.</p>
  
  <p>How can I use the value returned by this subclause to set the values (identically) of multiple rows used by the <code>UPDATE</code> statement?</p>
  
  <p><em>Edit</em>: Perhaps the question was a little unclear originally, so adding some example before/after data.</p>
  
  <p>Before:</p>
  
  <pre><code>MCL_Row  S_Type  Active  IsHeader
  1        1       1       1
  2        1       1       0
  3        1       0       0
  4        2       1       1
  5        2       1       0
  6        2       1       0
  </code></pre>
  
  <p>After setting S_Type=1 active via header:</p>
  
  <pre><code>MCL_Row  S_Type  Active  IsHeader
  1        1       1       1
  2        1       1       0
  3        1      &gt;1&lt;      0
  4        2       1       1
  5        2       1       0
  6        2       1       0
  </code></pre>
  
  <p>After setting S_Type=1 inactive via header:</p>
  
  <pre><code>MCL_Row  S_Type  Active  IsHeader
  1        1      &gt;0&lt;      1
  2        1      &gt;0&lt;      0
  3        1       0       0
  4        2       1       1
  5        2       1       0
  6        2       1       0
  </code></pre>