title: How to ensure that MySQL rows are unique?
body: <p>I am trying to insert a row into a MySQL table, with the condition that the row itself has to be unique. 
  So for example, the row would have <code>id</code>, <code>name</code> and <code>address</code>, but we can't have an insert with duplicate name and address.
  I tried doing a select before inserting, to make sure I don't find the result, but it doesn't seem to be working.
  I am currently trying to do this before inserting:</p>
  
  <pre><code>SELECT * FROM locations WHERE cityId = $cityId AND countyId = $countyId AND stateId = $stateId AND countryId = $countyId AND district = $district;
  </code></pre>
  
  <p>EDIT:
  All those fields are allowed to duplicate, they just can't duplicate all at the same time.</p>