title: SQL insert into values where not exists
body: <p>I am trying to execute the following query </p>
  
  <pre><code>INSERT INTO test (trans_id, voucher_id, trans_date, ledger_code_1,
                    company_code,trans_type, trans_amount) 
  VALUES (1, 1,'2012/04/01','2001', '8523a95b-5425-46be-89ed-ebd592846845',
          'Payment', -30)   
  WHERE NOT EXISTS(SELECT trans_id, ledger_code_1 
                   FROM test 
                   WHERE trans_id = 1 AND ledger_code_1 = '2001')
  </code></pre>
  
  <p>its giving error. where am i wrong ?</p>
  
  <blockquote>
    <p>1064 - You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near <strong>where not exists(select trans_id,ledger_code_1 from test where
    **trans_id = 1 and' at line 1</strong></p>
  </blockquote>
  
  <p>is there any other solution ? i have primary key as auto number..</p>