title: Only Insert if unique(check 2 rows)
body: <p>I am learning SQL and I am in situation where I have to INSERT values into database only if it do not exist already.</p>
  
  <p>My tableview structure is like this:</p>
  
  <pre><code>+----------+-----------+-----+-----+
  | first_id | second_id | timestamp |
  +----------+-----------+-----------+
  </code></pre>
  
  <p>I Want to insert only if there is not same <code>first_id</code> and <code>second_id</code> e.g if in table there is <code>first_id 1</code> and <code>second_id 2</code> and I am adding it again, I do not want to add it anymore. So if the first_id and second_id rows already have values 1 and 2 then do not add but if <code>first_id</code> is 3 and <code>second_id</code> is 1 then I would allow the inserting.</p>
  
  <p>This is my query ATM:</p>
  
  <pre><code>INSERT INTO  `testtable`.`ids` (`first_id`, `second_id`) VALUES (:first_id, :second_id)
  </code></pre>
  
  <p>And like this I tried with <code>NOT EXISTS</code> but it is not working:</p>
  
  <pre><code>NOT EXISTS (SELECT first_id, second_id FROM `testtable`.`ids` WHERE first_id = : first_id AND second_id = : second_id) INSERT INTO  `testtable`.`ids` (`first_id `, `second_id `) VALUES (: first_id, : second_id)
  </code></pre>
  
  <p>The last mentioned query gives me Syntax error but once I even got the integrity violation and it told me to check documentation.</p>
  
  <p>I am executing my queries using PHP <code>-&gt;query("");</code> function.</p>
  
  <p>I tried to do like <code>IF NOT EXISTS</code> and <code>NOT EXISTS</code> but those didn't work. How should I approach to this?</p>