I need to change rows in my DB using 2 arrays, first stores names of rows which i need to change, second stores val. I've added the code , to understand what I want to do. Can i do it with 1 request to my DB
func update_1(){
key := []string{"Name1", "Name2", "Name4"}
val := []string{"1", "2", "4"}
for i, _ := range key{
_, err := db.Exec("UPDATE table SET val = $1 WHERE name = $2",val[i], key[i])
if err != nil {
errorLog.Println(err)
return
}
}
}