title: Incosistent rows updated between MySQL and go-sql-driver/mysql
body: <p>I'm trying to update a record in the database, and based on the <code>rowsAffected()</code> count I can decided whether the record exists or not. In which case if it doesn't (<code>rowsAffected() == 0</code>) I will run a insert query.</p>
  <pre class="lang-golang prettyprint-override"><code>func (u *UserService) NewAddress(l *models.Address) error {
      var err error
      db, err := database.GetConnection()
      if err != nil {
          return err
      }
      defer db.Close()
      sql := `UPDATE Locations SET Address = ?, StateId = ? WHERE Id = ?`
      query := `INSERT INTO Locations (UserId, StateId, Address, City, StreetName, StreetNumber, Code, Latitude, Longitude) VALUES(?,?,?,?,?,?,?,?,?)`
  
      stmt, err := db.Prepare(sql)
      if err != nil {
          return err
      }
      results, err := stmt.Exec(&quot;Port St Johns, South Africa&quot;, l.StateId, l.Id)
      if err != nil {
          return err
      }
      fmt.Println(results.RowsAffected())
      if affected, err := results.RowsAffected(); err == nil {
          if affected == 0 {
              insert, err := db.Query(query, l.UserId, l.StateId, l.Address, l.City, l.StreetName, l.StreetNumber, l.Code, l.Latitude, l.Longitude)
              defer insert.Close()
              if err != nil {
                  return err
              }
          }
      }
      return nil
  }
  
  </code></pre>
  <p>However, the <code>RowsAffected()</code> func always returns 0 if the value of the column I'm updating e.i <code>Address</code> is the same as the one already stored in the database. It also returns 0 if it can't find the record I'm trying to update.</p>
  <p>If I run the same query directly on MySQL console however, even if the update (address) is exactly the same, it always returns <code>Update Rows</code> &gt;= 1 as long as the <code>WHERE</code> clause condition is met.</p>
  <pre class="lang-sql prettyprint-override"><code>UPDATE Locations 
  SET Address = &quot;Port St Johns&quot;, StateId = 2 
  WHERE Id = 102;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/O5q5A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O5q5A.png" alt="enter image description here" /></a></p>
  <p>Can I do this update any different? I'm trying to avoid a <code>select</code> query to check if the record exists before updating/inserting.</p>