title: golang sql driver's prepare statement
body: <p>With regards to golang's sql driver, what is the difference between the two statements below?</p>
  
  <pre><code>// store.DB is *sql.DB type
  rows, err := store.DB.Query(SQL, args ...)
  // err != nil
  defer rows.Close()
  </code></pre>
  
  <p>and</p>
  
  <pre><code>// store.DB is *sql.DB type
  stmt, err := store.DB.Prepare(SQL)
  // err != nil
  defer stmt.Close()
  
  rows, err := stmt.Query(args ...)
  // err != nil
  defer rows.Close()
  </code></pre>
  
  <p>It seems that they are the same? Are there any subtle difference?</p>
  
  <p><strong>Update</strong>:  </p>
  
  <p>We don't need to perform many <code>stmt.Exec</code> or <code>stmt.Query</code> after <code>db.Prepare</code>, only one <code>exec</code> or <code>query</code> is performed after each <code>prepare</code>. And when we use <code>db.Query</code> or <code>db.Exec</code>, we pass arguments to the methods instead of using raw SQL string (for security consideration).  </p>
  
  <p>I have found one reference links: <a href="http://go-database-sql.org/prepared.html" rel="noreferrer">http://go-database-sql.org/prepared.html</a><br>
  It seems that both way are using <strong>prepared statement</strong>, what's the difference?</p>