Skip to content

Instantly share code, notes, and snippets.

@grantpullen
Last active November 20, 2019 07:04
Show Gist options
  • Save grantpullen/dca203870fe0a2775858eed6179c263d to your computer and use it in GitHub Desktop.
Save grantpullen/dca203870fe0a2775858eed6179c263d to your computer and use it in GitHub Desktop.
Go ANY and IN clause in PostgreSQL

Replace the IN with ANY

v := []string{"1", "2", "3", "4"}
id := 1
q := "UPDATE users SET deleted = true WHERE id = $1 and org_id = ANY($2::bigint[])"
in := "{" + strings.Join(v, ",") + "}"

res, err := Db.Exec(q, id, param)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment