title: How to get ID of the last inserted row in MySQL and Go?
body: <p>How can I use this trick: <a href="https://stackoverflow.com/questions/1388025/how-to-get-id-of-the-last-updated-row-in-mysql">How to get ID of the last updated row in MySQL?</a> in Go (golang)?</p>
  
  <p>I am using the go-sql-driver. It should work with these two queries but how can I do it in Go?</p>
  
  <pre><code>INSERT INTO table (unique_id) VALUES ("test")
  ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id);
  
  SELECT LAST_INSERT_ID();
  </code></pre>