title: How to use `where in` with slice of ints
body: <p>From <a href="http://jinzhu.me/gorm/advanced.html#sql-builder" rel="nofollow">http://jinzhu.me/gorm/advanced.html#sql-builder</a>, I should be able to update multiple rows using WHERE IN with a single <code>(?)</code> and passing a slice to the single <code>?</code> as opposed to <code>WHERE IN (?,?,?,?)</code>. </p>
  
  <p>Example from jinzhu.me as follows: <code>db.Exec("UPDATE orders SET shipped_at=? WHERE id IN (?)", time.Now, []int64{11,22,33})</code>. Here is an example of gorm's tests showing it working. <a href="https://github.com/jinzhu/gorm/blob/021d7b33143de37b743d1cf660974e9c8d3f80ea/main_test.go#L449" rel="nofollow">https://github.com/jinzhu/gorm/blob/021d7b33143de37b743d1cf660974e9c8d3f80ea/main_test.go#L449</a></p>
  
  <p>This doesnt work for me however: </p>
  
  <pre><code>var availableIds []int
  for _, p := range v.Products {
      availableIds = append(availableIds, p.Id)
  }
  
  log.Println(availableIds)
  
  db.Exec("UPDATE product_supplier SET deleted_at=? WHERE supplier_id = ? AND sku NOT IN (?)", time.Now(), 3, availableIds)
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>2016/04/19 07:48:44 [336 338 337 306 329 94 79 43 57 313 108 122 126 127 124 125 123 221 93 330 335 333 312]
  
  (sql: expected 2 arguments, got 25)
  </code></pre>
  
  <p>When I try hardcoding, I get the same issue:</p>
  
  <pre><code>db.Exec("UPDATE product_supplier SET deleted_at=? WHERE supplier_id = ? AND sku NOT IN (?)", time.Now(), 3, []int{313, 108})
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>(sql: expected 2 arguments, got 4)
  </code></pre>
  
  <p><strong>Solution:</strong></p>
  
  <p>The code is not actually bugged at all. Was me being silly - I had an extra parameter in my actual code than I should have. I just didn't translate it for stack overflow correctly. My bad.</p>