title: Check if record exist
body: <p>I have CSV files and I need to do something like this before inserting data in my table:</p>
  
  <pre><code>table fields
  id = primary id and auto-increment
  house_no
  city_code
  prv_code
  cty_code
  
  
  if (house_no,city_code,prv_code,cty_code) exists = ignore insert
  else if (house_no,city_code,prv_code,cty_code) is null = ignore insert
  else (house_no,city_code,prv_code,cty_code) !exist = insert
  </code></pre>
  
  <p>My original code just re-inserts the same values because the primary key <strong>id</strong> is just creating a new id for it and as a result I have duplicates.</p>
  
  <p>I need to do this to avoid duplicates. I tried <code>INSERT IGNORE</code> and <code>REPLACE</code> but I need a unique key and all fields may have a value which is the same (like they may have different <code>house_no</code> but the same <code>prv_code</code> or <code>cty_code</code> or something like that). I just want to check if the record exist before I insert it.</p>