title: MySQL code to insert a username and password into a table if a licencing key exists in that table
body: <p>I am trying to accomplish a simple licensing system in golang and have tried numerous ways to get it to work. Basically, I have input a couple of random licensing keys into my database and my golang program should check to see if the user-input key exists and if it does then add the user specified username and password into the database to login later.</p>
  
  <p>This is the code that I have that hasn't been working: </p>
  
  <pre><code>"IF EXISTS (SELECT * FROM login WHERE LK = "+reglicenceEntry.Text()+") THEN 
   INSERT INTO `login` (`Username`, `Password`, `LK`) VALUES 
   ('"+regusernameEntry.Text()+"', '"+regpasswordEntry.Text()+"', ''); "
  </code></pre>
  
  <p>This is the golang error:</p>
  
  <blockquote>
    <p>Error 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 'IF EXISTS (SELECT * FROM login WHERE LK = '5qp515YHXEmSDzwqgoJh') THEN INSERT IN' at line 1</p>
  </blockquote>
  
  <p>Thanks so much!</p>