title: PostgreSQL: Exact Match on Multiple Columns
body: <h2>Background</h2>
  <p>I have a table that contains multiple ID fields like so:</p>
  <pre><code>work_id TEXT DEFAULT NULL,
  card_id TEXT DEFAULT NULL,
  employee_id TEXT DEFAULT NULL,
  school_id TEXT DEFAULT NULL
  </code></pre>
  <h2>Find exact matches</h2>
  <p>And I need to find the rows where all of these fields match exactly. My initial syntax for this comparison would be:</p>
  <pre><code>SELECT * FROM table
  WHERE
    work_id = card_id AND
    work_id = employee_id AND
    work_id = school_id;
  </code></pre>
  <h2>Find any non-matching rows</h2>
  <p>Conversely, I also need to find the rows where all of these fields do not match exactly. My initial syntax for this comparison would be:</p>
  <pre><code>SELECT * FROM table
  WHERE
    work_id NOT = card_id OR
    work_id NOT = employee_id OR
    work_id NOT = school_id;
  </code></pre>
  <h2>Question</h2>
  <p>Is there an easier way to do this comparison across more than two columns at a time? Is there some sort of array operator that will find matching or non-matching values across multiple columns?</p>
  <h2>Future-Proofing the Code</h2>
  <p>I ask this because if the number of columns being compared is high, this type of code could prove unwieldly and hard to maintain down the road. For example, if later on, we add another ID column to the table, I would need to manually add a new line to the comparison logic to include the new column.</p>