title: SQL statements with equals vs in
body: <p>Say that someone came up to you and said we're going to cut down the amount of SQL that we write by replacing equals with <code>IN</code>. The use would be both for single scalar values and lists of numbers.</p>
  <pre><code>SELECT * 
  FROM table 
  WHERE id = 1
  </code></pre>
  <p>OR</p>
  <pre><code>SELECT * 
  FROM table 
  WHERE id IN (1)
  </code></pre>
  <p>Are these statement equivalent to what the <em>optimizer</em> produces?</p>
  <p>This looks really simple on the surface, but it leads to simplification for two reasons:</p>
  <ol>
  <li>large blocks of SQL don't need to be duplicated</li>
  <li>we don't overuse dynamic SQL.</li>
  </ol>
  <hr />
  <h2>Example</h2>
  <p>This is a contrived example, but consider the following:</p>
  <pre><code>SELECT a.*
  FROM tablea a
       JOIN tableb b      ON a.id  = b.id
       JOIN tablec c      ON b.id2 = c.id2
       LEFT JOIN tabled d ON c.id3 = c.id3
  WHERE d.type = 1
  </code></pre>
  <p>... and the same again for the more than one case:</p>
  <pre><code>SELECT a.*
  FROM tablea a 
       JOIN tableb b      ON a.id  = b.id
       JOIN tablec c      ON b.id2 = c.id2
       LEFT JOIN tabled d ON c.id3 = c.id3
  WHERE d.type IN (1, 2, 3, 4)
  </code></pre>
  <p>(this isn't even a large statement)</p>
  <p>Conceivably you could do <em>string concatenation</em>, but this isn't desirable in light of ORM usage, and dynamic SQL string concatenation always starts off with good intentions (at least in these parts).</p>