title: Loop over a list and compare an item in a list to other two simultaneously
body: <p><a href="https://stackoverflow.com/questions/16603282/how-to-compare-each-item-in-a-list-with-the-rest-only-once">This itertools example</a> compares only 1 item to another. I need to compare 1 item to 2 others at the same time.</p>
  <p><code>my_list = [10, 420, 11]</code></p>
  <p>I need to be able to compare these items in the query below, with the following comparisons:</p>
  <ul>
  <li>10 to both 420 and 11 (as in the code below),</li>
  <li>420 to both 10 and 11,</li>
  <li>11 to both 420 and 10.</li>
  </ul>
  <p>I'm running this inside of a SQL query.</p>
  <pre><code>SELECT COUNT(*) FROM (
     SELECT app FROM vendor WHERE vendor=10 AND active
     INTERSECT
     SELECT app FROM vendor WHERE vendor NOT IN (420, 11) AND active = 0
     )
  </code></pre>