Advertisement
arxeiss

IN operator

May 9th, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.42 KB | None | 0 0
  1. func AddAttachments(templateId int, attachmentIds []int) (sql.Result, error) {
  2.     glue := fmt.Sprintf("),(%d,", templateId)
  3.     valuesSyntax := strings.Join(IntSliceToStringSlice(attachmentIds), glue)
  4.     valuesSyntax = fmt.Sprintf("(%d,%s)", templateId, valuesSyntax)
  5.  
  6.     // Return the query in format ... VALUES (1,20),(1,21),...
  7.     return db.Exec(fmt.Sprintf(`INSERT OR IGNORE INTO templates_attachments VALUES %v`, valuesSyntax))
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement