title: MySQL check for uniqueness of a set of attributes?
body: <p>What I'm trying to do is, I need to perform a uniqueness validation. However, I am not simply checking <em>&quot;if the name iggy already exists in DB?&quot;</em>. I need to check for uniqueness of a set of attributes.</p>
  <p>Here's what I mean by checking for uniqueness of a set of attributes. Let's say that I need to check for the uniqueness of the columns/ attributes: <code>type</code>, <code>partNum</code>, and <code>name</code>. I need to check if a set of <code>type</code>, <code>partNum</code>, and <code>name</code> of a row is unique.</p>
  <ol>
  <li>If I find two rows with the same <code>type</code> and <code>name</code> but they have different <code>partNum</code>, they are considered unique.</li>
  <li>If I find two rows with the same <code>type</code> but they have different <code>name</code> and <code>partNum</code>, they are considered unique.</li>
  <li>If I find two rows with the same <code>type</code>, <code>name</code>, and <code>partNum</code>, they are NOT unique.</li>
  </ol>
  <pre><code>id type  partNum  name
  -----------------------
  1  A     partA    nameA  # assume this exists
  2  A     partA    nameB  # unique
  3  A     partB    nameA  # unique
  4  B     partA    nameA  # unique
  5  A     partA    nameA  # NOT unique b/c type, partNum, and name match with 1
  </code></pre>
  <p>What is a good strategy / MySQL code to compare attribute sets from the <code>type</code>, <code>partNum</code>, and <code>name</code> columns?</p>