title: Golang database/sql.DB.QueryRow with multiple args
body: <p>I want to execute a query something like this (using MySql):</p>
  
  <pre><code>select * from user where id = 5
  </code></pre>
  
  <p>Ex 1. This returns <code>err = sql.ErrNoRows</code>:</p>
  
  <pre><code>err := db.QueryRow("select * from user where ? = ?", f, v).Scan(&amp;user.Id, etc...)
  </code></pre>
  
  <p>Ex 2. Since the above doesn't work, I am doing it this way, which works but doesn't feel right:</p>
  
  <pre><code>err := db.QueryRow("select * from user where "+f+" = ?", v).Scan(&amp;user.Id, etc...)
  </code></pre>
  
  <p>What is wrong in Ex. 1? Is Ex 2. an acceptable way to do this?</p>
  
  <p>EDIT</p>
  
  <p>From the link in the comments I can do it a third way.</p>
  
  <p>Ex 3:</p>
  
  <pre><code>q := fmt.Sprintf("select * from user where %s = ?", f)
  err := db.QueryRow(q, v).Scan(&amp;user.Id, etc...)
  </code></pre>